-
Notifications
You must be signed in to change notification settings - Fork 6
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
12 changed files
with
149 additions
and
72 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 @@ | ||
'use strict' | ||
|
||
const runScript = require('../lib/run-script') | ||
const dockerhubCallback = require('../lib/dockerhub-callback') | ||
|
||
module.exports = (options, callback) => { | ||
if (!options) { | ||
return callback('Missing required input: options') | ||
} | ||
if (!options.callbackUrl) { | ||
return callback('Missing required input: options.callbackUrl') | ||
} | ||
if (!options.script) { | ||
return callback('Missing required input: options.script') | ||
} | ||
runScript(options, (err, data) => { | ||
if (err) { | ||
return callback(err) | ||
} else { | ||
dockerhubCallback(data.options, (err, result) => { | ||
if (err) { | ||
return callback(err) | ||
} else { | ||
return callback(null, { callback: result.text, script: data.result }) | ||
} | ||
}) | ||
} | ||
}) | ||
} |
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,2 @@ | ||
echo "I fail" | ||
exit 1 |
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,31 @@ | ||
'use strict' | ||
|
||
const tap = require('tap') | ||
const hookAction = require('../lib/hook-action') | ||
|
||
tap.test('hookAction missing options', (t) => { | ||
const options = false | ||
hookAction(options, (err) => { | ||
t.equal(err, 'Missing required input: options', 'Missing options ok') | ||
t.end() | ||
}) | ||
}) | ||
|
||
tap.test('hookAction missing options.callbackUrl', (t) => { | ||
const options = {} | ||
hookAction(options, (err) => { | ||
t.equal(err, 'Missing required input: options.callbackUrl', 'Missing options.callbackUrl ok') | ||
t.end() | ||
}) | ||
}) | ||
|
||
tap.test('hookAction missing options.script', (t) => { | ||
const options = { | ||
callbackUrl: true | ||
} | ||
hookAction(options, (err) => { | ||
t.equal(err, 'Missing required input: options.script', 'Missing options.script ok') | ||
t.end() | ||
}) | ||
}) | ||
|
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,39 +1,53 @@ | ||
'use strict' | ||
|
||
const tap = require('tap') | ||
const Hapi = require('hapi') | ||
const runScript = require('../lib/run-script') | ||
const server = new Hapi.Server() | ||
|
||
tap.test('runScript missing options', (t) => { | ||
const options = false | ||
const result = runScript(options) | ||
t.equal(result.message, 'Missing required input: options', 'runScript missing options ok') | ||
t.end() | ||
runScript(options, (err) => { | ||
t.equal(err, 'Missing required input: options', 'runScript missing options ok') | ||
t.end() | ||
}) | ||
}) | ||
|
||
tap.test('runScript missing options.request', (t) => { | ||
tap.test('runScript missing options.script', (t) => { | ||
const options = {} | ||
const result = runScript(options) | ||
t.equal(result.message, 'Missing required input: options.request', 'runScript missing options.request ok') | ||
t.end() | ||
runScript(options, (err) => { | ||
t.equal(err, 'Missing required input: options.script', 'runScript missing options.script ok') | ||
t.end() | ||
}) | ||
}) | ||
|
||
tap.test('runScript missing options.script', (t) => { | ||
tap.test('runScript script do not exist', (t) => { | ||
const options = { | ||
request: server | ||
script: 'dengalevandrer' | ||
} | ||
const result = runScript(options) | ||
t.equal(result.message, 'Missing required input: options.script', 'runScript missing options.script ok') | ||
t.end() | ||
runScript(options, (err) => { | ||
t.match(err, 'does not exist', 'runScript script do not exist ok') | ||
t.end() | ||
}) | ||
}) | ||
|
||
tap.test('runScript script do not exist', (t) => { | ||
tap.test('runScript run fail script', (t) => { | ||
const options = { | ||
request: server, | ||
script: 'dengalevandrer' | ||
script: 'fail.sh' | ||
} | ||
runScript(options, (err, data) => { | ||
t.equal(err.code, 1, 'runScript fails ok') | ||
t.end() | ||
}) | ||
}) | ||
|
||
tap.test('runScript run through', (t) => { | ||
const options = { | ||
script: 'hello.sh' | ||
} | ||
const result = runScript(options) | ||
t.match(result.message, 'does not exist', 'runScript script do not exist ok') | ||
t.end() | ||
runScript(options, (err, data) => { | ||
if (err) { | ||
throw err | ||
} | ||
t.equal(data.result, 'Running dummy script\n', 'runScript runs ok') | ||
t.end() | ||
}) | ||
}) |