-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix #92 * throw error instead of exit process * cover non-zero exit code cases
- Loading branch information
1 parent
b66e2e8
commit 99564bf
Showing
5 changed files
with
102 additions
and
40 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
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 |
---|---|---|
@@ -1,7 +1,38 @@ | ||
const cli = require('../src/cli'); | ||
const path = require('path'); | ||
const exec = require('child_process').exec; | ||
|
||
function runCommand(cmd, cwd) { | ||
return new Promise(resolve => { | ||
exec(cmd, { cwd }, (error, stdout, stderr) => { | ||
resolve({ | ||
code: error && error.code ? error.code : 0, | ||
error, | ||
stdout, | ||
stderr, | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
describe('Cli', () => { | ||
it('is a function', () => { | ||
expect(typeof cli).toBe('function'); | ||
}); | ||
|
||
it('should exit process with non-zero code', () => { | ||
const workDir = path.resolve(__dirname, '../'); | ||
const cmd = `node src/index tests/fixtures/code/swagger-api-with-error.js --base tests/fixtures/project/swaggerBase.json`; | ||
return runCommand(cmd, workDir).then(result => { | ||
expect(result.code).not.toBe(0); | ||
}); | ||
}); | ||
|
||
it('should exit process with zero code', () => { | ||
const workDir = path.resolve(__dirname, '../'); | ||
const cmd = `node src/index tests/fixtures/code/swagger-api.js --base tests/fixtures/project/swaggerBase.json`; | ||
return runCommand(cmd, workDir).then(result => { | ||
expect(result.code).toBe(0); | ||
}); | ||
}); | ||
}); |
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,19 @@ | ||
|
||
/** | ||
* @api [post] /pets | ||
* requestBody: | ||
* required: true | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* required: | ||
* - name | ||
* properties: | ||
* name: | ||
* type: string | ||
* properties there should be an error | ||
*/ | ||
router.post('/pets', () => { | ||
|
||
}); |