test(pre): verification hook

This commit is contained in:
Christoph Witzko 2015-05-15 19:29:53 +02:00
parent 245f918201
commit 1f70215ffe
3 changed files with 51 additions and 0 deletions

View File

@ -5,6 +5,7 @@ var test = require('tape')
var createModule = require('./lib/create-module')
require('./scenarios/custom-analyzer')(test, createModule)
require('./scenarios/custom-verification')(test, createModule)
require('./scenarios/ignore')(test, createModule)
require('./scenarios/prepublish')(test, createModule)
require('./scenarios/postpublish')(test, createModule)

View File

@ -0,0 +1,5 @@
'use strict'
module.exports = function (opts, cb) {
cb(null, !(opts.commits.length % 2))
}

View File

@ -0,0 +1,45 @@
'use strict'
var path = require('path')
var efh = require('error-first-handler')
var nixt = require('nixt')
module.exports = function (test, createModule) {
createModule({
release: {
verification: path.join(__dirname, '../lib/custom-verification')
}
}, efh()(function (name, cwd) {
test('custom-verification', function (t) {
t.test('even commit count', function (t) {
t.plan(1)
nixt()
.cwd(cwd)
.env('CI', true)
.env('npm_config_registry', 'http://127.0.0.1:4873/')
.exec('git commit --allow-empty -m "feat: commit"')
.run('npm run prepublish')
.code(0)
.end(function (err) {
t.error(err, 'nixt')
})
})
t.test('odd commit count', function (t) {
t.plan(1)
nixt()
.cwd(cwd)
.env('CI', true)
.env('npm_config_registry', 'http://127.0.0.1:4873/')
.exec('git commit --allow-empty -m "feat: commit"')
.run('npm run prepublish')
.code(1)
.stdout(/Verification failed/)
.end(function (err) {
t.error(err, 'nixt')
})
})
})
}))
}