-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
2,675 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const fs = jest.genMockFromModule('fs-extra'); | ||
|
||
let fsStatReject = true; | ||
let fsRemoveReject = true; | ||
let retFsPathExistsSync = false; | ||
|
||
function __setFsStatReject(reject) { | ||
fsStatReject = reject; | ||
} | ||
|
||
function __setFsRemoveReject(reject) { | ||
fsRemoveReject = reject; | ||
} | ||
|
||
function __setRetFsPathExistsSync(value) { | ||
retFsPathExistsSync = value; | ||
} | ||
|
||
fs.__setFsStatReject = __setFsStatReject; | ||
fs.__setFsRemoveReject = __setFsRemoveReject; | ||
fs.__setRetFsPathExistsSync = __setRetFsPathExistsSync; | ||
|
||
fs.stat = jest.fn((path) => { | ||
if (fsStatReject) { | ||
return Promise.reject(); | ||
} | ||
return Promise.resolve(); | ||
}); | ||
|
||
fs.remove = jest.fn((path) => { | ||
if (fsRemoveReject) return Promise.reject(); | ||
return Promise.resolve(); | ||
}); | ||
|
||
fs.pathExistsSync = jest.fn((path) => { | ||
return retFsPathExistsSync; | ||
}); | ||
|
||
module.exports = fs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
let gitIsRepoRet = true; | ||
let gitTagsReject = true; | ||
let gitCloneReject = true; | ||
let gitPullReject = true; | ||
let gitResetReject = true; | ||
let gitCleanReject = true; | ||
let gitBranchLocalReject = true; | ||
let gitCheckoutBranchReject = true; | ||
let gitCheckoutReject = true; | ||
let retTags = []; | ||
let retLocalBranches = {}; | ||
|
||
function __setGitIsRepoRet(value) { | ||
gitIsRepoRet = value; | ||
} | ||
|
||
function __setRepoTags(tags) { | ||
retTags = tags; | ||
} | ||
|
||
function __setGitTagsReject(reject) { | ||
gitTagsReject = reject; | ||
} | ||
|
||
function __setGitCloneReject(reject) { | ||
gitCloneReject = reject; | ||
} | ||
|
||
function __setGitPullReject(reject) { | ||
gitPullReject = reject; | ||
} | ||
|
||
function __setGitResetReject(reject) { | ||
gitResetReject = reject; | ||
} | ||
|
||
function __setGitCleanReject(reject) { | ||
gitCleanReject = reject; | ||
} | ||
|
||
function __setGitBranchLocalReject(reject) { | ||
gitBranchLocalReject = reject; | ||
} | ||
|
||
function __setLocalBranches(branches) { | ||
retLocalBranches = branches; | ||
} | ||
|
||
function __setGitCheckoutBranchReject(reject) { | ||
gitCheckoutBranchReject = reject; | ||
} | ||
|
||
function __setGitCheckoutReject(reject) { | ||
gitCheckoutReject = reject; | ||
} | ||
|
||
const gitObject = { | ||
checkIsRepo: jest.fn(() => Promise.resolve(gitIsRepoRet)), | ||
tags: jest.fn(() => { | ||
if (gitTagsReject) return Promise.reject(); | ||
return Promise.resolve({ all: retTags }); | ||
}), | ||
clone: jest.fn((source, dest) => { | ||
if (gitCloneReject) return Promise.reject(); | ||
|
||
return Promise.resolve(); | ||
}), | ||
pull: jest.fn(() => { | ||
if (gitPullReject) return Promise.reject(); | ||
return Promise.resolve(); | ||
}), | ||
reset: jest.fn((type) => { | ||
if (gitResetReject) return Promise.reject(); | ||
return Promise.resolve(); | ||
}), | ||
clean: jest.fn((opts) => { | ||
if (gitCleanReject) return Promise.reject(); | ||
return Promise.resolve(); | ||
}), | ||
branchLocal: jest.fn(() => { | ||
if (gitBranchLocalReject) return Promise.reject(); | ||
return Promise.resolve({ branches: retLocalBranches }); | ||
}), | ||
checkoutBranch: jest.fn((remote, local) => { | ||
if (gitCheckoutBranchReject) return Promise.reject(); | ||
return Promise.resolve(); | ||
}), | ||
checkout: jest.fn(() => { | ||
if (gitCheckoutReject) return Promise.reject(); | ||
return Promise.resolve(); | ||
}), | ||
}; | ||
|
||
const git = jest.fn((path) => { | ||
return gitObject; | ||
}); | ||
|
||
git.__setGitIsRepoRet = __setGitIsRepoRet; | ||
git.__setRepoTags = __setRepoTags; | ||
git.__setGitTagsReject = __setGitTagsReject; | ||
git.__setGitCloneReject = __setGitCloneReject; | ||
git.__setGitPullReject = __setGitPullReject; | ||
git.__setGitResetReject = __setGitResetReject; | ||
git.__setGitCleanReject = __setGitCleanReject; | ||
git.__setGitBranchLocalReject = __setGitBranchLocalReject; | ||
git.__setLocalBranches = __setLocalBranches; | ||
git.__setGitCheckoutBranchReject = __setGitCheckoutBranchReject; | ||
git.__setGitCheckoutReject = __setGitCheckoutReject; | ||
|
||
module.exports = git; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
verbose: true, | ||
collectCoverage: true, | ||
setupFiles: [path.resolve(__dirname, 'jestSetEnv.js')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
process.env.WORKDIR = '/tmp/serverTest'; | ||
// process.env.DEBUG = 'server,git,compile'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const { server } = require('./server'); | ||
const { listenPort } = require('./config/config'); | ||
|
||
server.listen(listenPort, () => { | ||
console.log(`Server started on port ${listenPort}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const fsMock = require('fs-extra'); | ||
const { compileCode } = require('../compile'); | ||
|
||
describe('compile.js test', () => { | ||
describe('testing getImageName', () => { | ||
it('should return empty string if file with current image cannot be found', async (done) => { | ||
const define = await compileCode('socket', 'board'); | ||
done(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.