-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: return release info in
publish
and add success
and fail
h…
…ooks (#11)
- Loading branch information
Showing
6 changed files
with
119 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import test from 'ava'; | ||
import {stub} from 'sinon'; | ||
import {fail} from '..'; | ||
|
||
stub(process.stdout, 'write'); | ||
stub(process.stderr, 'write'); | ||
|
||
test.beforeEach(t => { | ||
// Mock logger | ||
t.context.log = stub(); | ||
t.context.error = stub(); | ||
t.context.logger = {log: t.context.log, error: t.context.error}; | ||
}); | ||
|
||
test.serial('Return the value fail script wrote to stdout', async t => { | ||
const pluginConfig = { | ||
cmd: './test/fixtures/echo-args.sh', | ||
}; | ||
const params = {logger: t.context.logger}; | ||
|
||
await t.notThrows(fail(pluginConfig, params)); | ||
}); | ||
|
||
test.serial('Throw "Error" if the fail script does not returns 0', async t => { | ||
const pluginConfig = {cmd: 'exit 1'}; | ||
const params = {logger: t.context.logger}; | ||
|
||
await t.throws(fail(pluginConfig, params), Error); | ||
}); |
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,29 @@ | ||
import test from 'ava'; | ||
import {stub} from 'sinon'; | ||
import {success} from '..'; | ||
|
||
stub(process.stdout, 'write'); | ||
stub(process.stderr, 'write'); | ||
|
||
test.beforeEach(t => { | ||
// Mock logger | ||
t.context.log = stub(); | ||
t.context.error = stub(); | ||
t.context.logger = {log: t.context.log, error: t.context.error}; | ||
}); | ||
|
||
test.serial('Return the value success script wrote to stdout', async t => { | ||
const pluginConfig = { | ||
cmd: './test/fixtures/echo-args.sh', | ||
}; | ||
const params = {logger: t.context.logger}; | ||
|
||
await t.notThrows(success(pluginConfig, params)); | ||
}); | ||
|
||
test.serial('Throw "Error" if the success script does not returns 0', async t => { | ||
const pluginConfig = {cmd: 'exit 1'}; | ||
const params = {logger: t.context.logger}; | ||
|
||
await t.throws(success(pluginConfig, params), Error); | ||
}); |