chore: remove babel, fix integration tests
This commit removes babel/es6 from all source and test files, because it was introducing a lot of overhead and only little gain. This commit fixes and enables integration tests on Travis. This commit fixes #153 and #151 along the way. _Originally this commit should have only removed babel, but without working tests that's a bit too hairy._ _I only realized that half way into removing babel/es6, so things are all over the place now._ Closes #153, Closes #151
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const nixt = require('nixt')
|
||||
var nixt = require('nixt')
|
||||
|
||||
module.exports = function (cwd, uri) {
|
||||
return nixt()
|
||||
@@ -7,8 +7,6 @@ module.exports = function (cwd, uri) {
|
||||
.env('NPM_EMAIL', 'integration@test.com')
|
||||
.env('GH_TOKEN', 'ghtoken')
|
||||
.env('CI', 'true')
|
||||
.env('TRAVIS', 'true')
|
||||
.env('TRAVIS_BRANCH', 'master')
|
||||
.env('npm_config_registry', uri)
|
||||
.clone()
|
||||
}
|
||||
|
||||
+17
-26
@@ -1,40 +1,31 @@
|
||||
const { exec } = require('child_process')
|
||||
const { join } = require('path')
|
||||
const { writeFileSync } = require('fs')
|
||||
var exec = require('child_process').exec
|
||||
var join = require('path').join
|
||||
var writeFileSync = require('fs').writeFileSync
|
||||
|
||||
const mkdirp = require('mkdirp')
|
||||
var mkdirp = require('mkdirp')
|
||||
|
||||
module.exports = function (name, cb) {
|
||||
const cwd = join(__dirname, '../tmp', name)
|
||||
module.exports = function (name, registry, cb) {
|
||||
var cwd = join(__dirname, '../tmp', name)
|
||||
|
||||
mkdirp.sync(cwd)
|
||||
|
||||
writeFileSync(join(cwd, '.npmrc'), `
|
||||
//localhost:1337/registry/_design/app/_rewrite/:username=integration
|
||||
//localhost:1337/registry/_design/app/_rewrite/:email=integration@test.com`, null, 2)
|
||||
|
||||
writeFileSync(join(cwd, 'package.json'), JSON.stringify({
|
||||
name,
|
||||
name: name,
|
||||
repository: {
|
||||
url: 'git+https://github.com/semantic-release/test'
|
||||
},
|
||||
_npmUser: {
|
||||
name: 'integration',
|
||||
email: 'integration@test.com'
|
||||
},
|
||||
maintainers: [{
|
||||
name: 'integration',
|
||||
email: 'integration@test.com'
|
||||
}]
|
||||
release: {
|
||||
verifyConditions: '../../../src/lib/plugin-noop'
|
||||
}
|
||||
}, null, 2))
|
||||
|
||||
exec(`
|
||||
git init &&
|
||||
git config user.email "integration@test" &&
|
||||
git config user.name "Integration Test" &&
|
||||
git add . &&
|
||||
git commit -m "chore: root"`
|
||||
, {cwd}, (err, stdout, stderr) => {
|
||||
exec(
|
||||
'git init && ' +
|
||||
'git config user.email "integration@test" && ' +
|
||||
'git config user.name "Integration Test" && ' +
|
||||
'git add . && ' +
|
||||
'git commit -m "chore: root"'
|
||||
, {cwd: cwd}, function (err, stdout, stderr) {
|
||||
if (err) {
|
||||
console.log(stdout, stderr)
|
||||
return cb(err)
|
||||
|
||||
@@ -4,10 +4,10 @@ const rawCommits = [
|
||||
]
|
||||
|
||||
module.exports = {
|
||||
exec: (command, cb) => {
|
||||
exec: function (command, cb) {
|
||||
if (/contains/.test(command)) {
|
||||
if (/notinhistory/.test(command)) return cb(new Error())
|
||||
return cb(null, `whatever\nmaster\n`)
|
||||
return cb(null, 'whatever\nmaster\n')
|
||||
}
|
||||
|
||||
cb(
|
||||
|
||||
+11
-5
@@ -1,6 +1,12 @@
|
||||
module.exports = () => ({
|
||||
authenticate: () => true,
|
||||
releases: {
|
||||
createRelease: (release, cb) => cb(null)
|
||||
module.exports = function () {
|
||||
return {
|
||||
authenticate: function () {
|
||||
return true
|
||||
},
|
||||
releases: {
|
||||
createRelease: function (release, cb) {
|
||||
cb(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
const { exec } = require('child_process')
|
||||
const { join } = require('path')
|
||||
var exec = require('child_process').exec
|
||||
|
||||
const opts = {
|
||||
cwd: join(__dirname, '../../test/registry')
|
||||
var opts = {
|
||||
cwd: __dirname
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
start: exec.bind(null, './start.sh', opts),
|
||||
stop: exec.bind(null, './stop.sh', opts),
|
||||
uri: 'http://localhost:15986/registry/_design/app/_rewrite/'
|
||||
uri: 'http://localhost:' + (process.env.TRAVIS === 'true' ? 5984 : 15986) + '/registry/_design/app/_rewrite/'
|
||||
}
|
||||
|
||||
+13
-9
@@ -7,25 +7,29 @@ cd $(dirname $0)
|
||||
|
||||
mkdir -p couch
|
||||
|
||||
# start couchdb as a background process, load local config, specify writable logfiles
|
||||
if [[ $TRAVIS = true ]]
|
||||
then
|
||||
echo 'starting couch with sudo'
|
||||
sudo couchdb -b -a local.ini -p couch/pid -o couch/stdout.log -e couch/stderr.log
|
||||
COUCH=http://admin:password@127.0.0.1:5984
|
||||
|
||||
curl -X PUT http://127.0.0.1:5984/_config/admins/admin -d '"password"'
|
||||
|
||||
curl -X PUT $COUCH/_config/couchdb/delayed_commits -d '"false"'
|
||||
curl -X PUT $COUCH/_config/couch_httpd_auth/users_db_public -d '"true"'
|
||||
curl -X PUT $COUCH/_config/couch_httpd_auth/public_fields -d '"appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev"'
|
||||
curl -X PUT $COUCH/_config/httpd/secure_rewrites -d '"false"'
|
||||
|
||||
else
|
||||
COUCH=http://admin:password@127.0.0.1:15986
|
||||
couchdb -b -a local.ini -p couch/pid -o couch/stdout.log -e couch/stderr.log
|
||||
# wait for couch to start
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# wait for couch to start
|
||||
sleep 5
|
||||
|
||||
COUCH=http://admin:password@127.0.0.1:15986
|
||||
|
||||
# create "registry" database
|
||||
curl -X PUT $COUCH/registry
|
||||
|
||||
# create sample npm user
|
||||
curl -X PUT $COUCH/_users/org.couchdb.user:integration -H Content-Type:application/json --data-binary '{"_id": "org.couchdb.user:integration","name": "integration","roles": [],"type": "user","password": "suchsecure","email": "integration@test.com"}'
|
||||
curl -X PUT $COUCH/_users/org.couchdb.user:integration -H Content-Type:application/json --data-binary '{"_id": "org.couchdb.user:integration", "name": "integration", "roles": [], "type": "user", "password": "suchsecure", "email": "integration@test.com"}'
|
||||
|
||||
# npm-registry-couchpp needs this variable set to run
|
||||
export DEPLOY_VERSION=nope
|
||||
|
||||
@@ -8,5 +8,6 @@ cd $(dirname $0)
|
||||
|
||||
cat couch/{couch,stdout,stderr}.log
|
||||
|
||||
cat couch/pid | xargs kill
|
||||
rm -rf couch
|
||||
rm -rf data
|
||||
|
||||
+22
-24
@@ -1,30 +1,27 @@
|
||||
const { join } = require('path')
|
||||
var join = require('path').join
|
||||
|
||||
const { test, tearDown } = require('tap')
|
||||
const rimraf = require('rimraf')
|
||||
var tap = require('tap')
|
||||
var rimraf = require('rimraf')
|
||||
|
||||
const registry = require('../registry')
|
||||
const testModule = require('../lib/test-module')
|
||||
const baseScenario = require('../lib/base-scenario')
|
||||
var registry = require('../registry')
|
||||
var testModule = require('../lib/test-module')
|
||||
var baseScenario = require('../lib/base-scenario')
|
||||
|
||||
test('change version', (t) => {
|
||||
var tearDown = tap.tearDown
|
||||
var test = tap.test
|
||||
|
||||
test('change version', {bail: process.env.TRAVIS === 'true'}, function (t) {
|
||||
t.plan(7)
|
||||
|
||||
registry.start((err) => {
|
||||
registry.start(function (err, stdout, stderr) {
|
||||
t.error(err, 'registry started')
|
||||
if (err) {
|
||||
t.end()
|
||||
t.bailout('registry not started')
|
||||
}
|
||||
if (err) return t.end()
|
||||
|
||||
testModule('change-version', (err, cwd) => {
|
||||
testModule('change-version', registry.uri, function (err, cwd) {
|
||||
t.error(err, 'test-module created')
|
||||
if (err) {
|
||||
t.end()
|
||||
t.bailout('test-module not created')
|
||||
}
|
||||
if (err) return t.end()
|
||||
|
||||
t.test('no version', (tt) => {
|
||||
t.test('no version', function (tt) {
|
||||
tt.plan(1)
|
||||
|
||||
baseScenario(cwd, registry.uri)
|
||||
@@ -35,7 +32,7 @@ test('change version', (t) => {
|
||||
.end(tt.error)
|
||||
})
|
||||
|
||||
t.test('initial version', (tt) => {
|
||||
t.test('initial version', function (tt) {
|
||||
tt.plan(1)
|
||||
|
||||
baseScenario(cwd, registry.uri)
|
||||
@@ -47,7 +44,7 @@ test('change version', (t) => {
|
||||
.end(tt.error)
|
||||
})
|
||||
|
||||
t.test('patch version', (tt) => {
|
||||
t.test('patch version', function (tt) {
|
||||
tt.plan(1)
|
||||
|
||||
baseScenario(cwd, registry.uri)
|
||||
@@ -59,7 +56,7 @@ test('change version', (t) => {
|
||||
.end(tt.error)
|
||||
})
|
||||
|
||||
t.test('feature version', (tt) => {
|
||||
t.test('feature version', function (tt) {
|
||||
tt.plan(1)
|
||||
|
||||
baseScenario(cwd, registry.uri)
|
||||
@@ -71,7 +68,7 @@ test('change version', (t) => {
|
||||
.end(tt.error)
|
||||
})
|
||||
|
||||
t.test('breaking version', (tt) => {
|
||||
t.test('breaking version', function (tt) {
|
||||
tt.plan(1)
|
||||
|
||||
baseScenario(cwd, registry.uri)
|
||||
@@ -86,10 +83,11 @@ test('change version', (t) => {
|
||||
})
|
||||
})
|
||||
|
||||
tearDown(() => {
|
||||
tearDown(function () {
|
||||
if (process.env.TRAVIS === 'true') return
|
||||
|
||||
function cb (err, stdout, stderr) {
|
||||
if (err) console.log(err)
|
||||
if (stdout) console.log(stdout)
|
||||
if (stderr) console.log(stderr)
|
||||
}
|
||||
|
||||
|
||||
+13
-10
@@ -1,13 +1,16 @@
|
||||
const test = require('tap').test
|
||||
const proxyquire = require('proxyquire')
|
||||
var test = require('tap').test
|
||||
var proxyquire = require('proxyquire')
|
||||
|
||||
const commits = proxyquire('../../dist/lib/commits', {
|
||||
var commits = proxyquire('../../src/lib/commits', {
|
||||
'npmlog': {
|
||||
error: function () {}
|
||||
},
|
||||
'child_process': require('../mocks/child-process')
|
||||
})
|
||||
|
||||
test('commits since last release', (t) => {
|
||||
t.test('get all commits', (tt) => {
|
||||
commits({lastRelease: {}, options: {branch: 'master'}}, (err, commits) => {
|
||||
test('commits since last release', function (t) {
|
||||
t.test('get all commits', function (tt) {
|
||||
commits({lastRelease: {}, options: {branch: 'master'}}, function (err, commits) {
|
||||
tt.error(err)
|
||||
tt.is(commits.length, 2, 'all commits')
|
||||
tt.is(commits[0].hash, 'hash-one', 'parsed hash')
|
||||
@@ -17,8 +20,8 @@ test('commits since last release', (t) => {
|
||||
})
|
||||
})
|
||||
|
||||
t.test('get commits since hash', (tt) => {
|
||||
commits({lastRelease: {gitHead: 'hash'}, options: {branch: 'master'}}, (err, commits) => {
|
||||
t.test('get commits since hash', function (tt) {
|
||||
commits({lastRelease: {gitHead: 'hash'}, options: {branch: 'master'}}, function (err, commits) {
|
||||
tt.error(err)
|
||||
tt.is(commits.length, 1, 'specified commits')
|
||||
tt.is(commits[0].hash, 'hash-one', 'parsed hash')
|
||||
@@ -28,8 +31,8 @@ test('commits since last release', (t) => {
|
||||
})
|
||||
})
|
||||
|
||||
t.test('get commits since hash', (tt) => {
|
||||
commits({lastRelease: {gitHead: 'notinhistory'}, options: {branch: 'notmaster'}}, (err, commits) => {
|
||||
t.test('get commits since hash', function (tt) {
|
||||
commits({lastRelease: {gitHead: 'notinhistory'}, options: {branch: 'notmaster'}}, function (err, commits) {
|
||||
tt.ok(err)
|
||||
tt.is(err.code, 'ENOTINHISTORY')
|
||||
tt.end()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const test = require('tap').test
|
||||
|
||||
const getRegistry = require('../../dist/lib/get-registry')
|
||||
const getRegistry = require('../../src/lib/get-registry')
|
||||
|
||||
test('get correct registry', (t) => {
|
||||
test('get correct registry', function (t) {
|
||||
t.is(getRegistry({
|
||||
name: 'publish-config',
|
||||
publishConfig: {
|
||||
@@ -10,20 +10,34 @@ test('get correct registry', (t) => {
|
||||
}},
|
||||
{}), 'a')
|
||||
|
||||
t.is(getRegistry({name: 'normal'}, {get: () => 'b'}), 'b')
|
||||
t.is(getRegistry({name: 'normal'}, {
|
||||
get: function () {
|
||||
return 'b'
|
||||
}
|
||||
}), 'b')
|
||||
|
||||
t.is(getRegistry({name: 'normal'}, {get: () => null}), 'https://registry.npmjs.org/')
|
||||
t.is(getRegistry({name: 'normal'}, {
|
||||
get: function () {
|
||||
return null
|
||||
}
|
||||
}), 'https://registry.npmjs.org/')
|
||||
|
||||
t.is(getRegistry({name: '@scoped/foo'}, {
|
||||
get: (input) => input === '@scoped/registry' ? 'c' : 'd'
|
||||
get: function (input) {
|
||||
return input === '@scoped/registry' ? 'c' : 'd'
|
||||
}
|
||||
}), 'c')
|
||||
|
||||
t.is(getRegistry({name: '@scoped/bar'}, {
|
||||
get: () => 'e'
|
||||
get: function () {
|
||||
return 'e'
|
||||
}
|
||||
}), 'e')
|
||||
|
||||
t.is(getRegistry({name: '@scoped/baz'}, {
|
||||
get: () => null
|
||||
get: function () {
|
||||
return null
|
||||
}
|
||||
}), 'https://registry.npmjs.org/')
|
||||
|
||||
t.end()
|
||||
|
||||
+32
-32
@@ -1,11 +1,11 @@
|
||||
const test = require('tap').test
|
||||
var test = require('tap').test
|
||||
|
||||
const plugins = require('../../dist/lib/plugins')
|
||||
var plugins = require('../../src/lib/plugins')
|
||||
|
||||
test('export plugins', (t) => {
|
||||
test('export plugins', function (t) {
|
||||
t.plan(5)
|
||||
|
||||
const defaultPlugins = plugins({})
|
||||
var defaultPlugins = plugins({})
|
||||
|
||||
t.is(typeof defaultPlugins.analyzeCommits, 'function')
|
||||
t.is(typeof defaultPlugins.generateNotes, 'function')
|
||||
@@ -14,51 +14,51 @@ test('export plugins', (t) => {
|
||||
t.is(typeof defaultPlugins.getLastRelease, 'function')
|
||||
})
|
||||
|
||||
test('plugin pipelines', (t) => {
|
||||
test('plugin pipelines', function (t) {
|
||||
t.plan(3)
|
||||
|
||||
t.test('get all results', (tt) => {
|
||||
const pipelinePlugins = plugins({
|
||||
t.test('get all results', function (tt) {
|
||||
var pipelinePlugins = plugins({
|
||||
verifyRelease: [
|
||||
'./dist/lib/plugin-noop',
|
||||
'./.test/mocks/plugin-result-a',
|
||||
'./.test/mocks/plugin-result-b'
|
||||
'./src/lib/plugin-noop',
|
||||
'./test/mocks/plugin-result-a',
|
||||
'./test/mocks/plugin-result-b'
|
||||
]
|
||||
})
|
||||
|
||||
pipelinePlugins.verifyRelease({}, (err, results) => {
|
||||
pipelinePlugins.verifyRelease({}, function (err, results) {
|
||||
tt.error(err)
|
||||
tt.same(results, [undefined, 'a', 'b'])
|
||||
tt.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('get first error', (tt) => {
|
||||
const pipelinePlugins = plugins({
|
||||
t.test('get first error', function (tt) {
|
||||
var pipelinePlugins = plugins({
|
||||
verifyConditions: [
|
||||
'./dist/lib/plugin-noop',
|
||||
'./.test/mocks/plugin-error-a',
|
||||
'./.test/mocks/plugin-error-b'
|
||||
'./src/lib/plugin-noop',
|
||||
'./test/mocks/plugin-error-a',
|
||||
'./test/mocks/plugin-error-b'
|
||||
]
|
||||
})
|
||||
|
||||
pipelinePlugins.verifyConditions({}, (err) => {
|
||||
pipelinePlugins.verifyConditions({}, function (err) {
|
||||
tt.is(err.message, 'a')
|
||||
tt.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('get error and only results before', (tt) => {
|
||||
const pipelinePlugins = plugins({
|
||||
t.test('get error and only results before', function (tt) {
|
||||
var pipelinePlugins = plugins({
|
||||
verifyRelease: [
|
||||
'./dist/lib/plugin-noop',
|
||||
'./.test/mocks/plugin-result-a',
|
||||
'./.test/mocks/plugin-error-b',
|
||||
'./.test/mocks/plugin-result-b'
|
||||
'./src/lib/plugin-noop',
|
||||
'./test/mocks/plugin-result-a',
|
||||
'./test/mocks/plugin-error-b',
|
||||
'./test/mocks/plugin-result-b'
|
||||
]
|
||||
})
|
||||
|
||||
pipelinePlugins.verifyRelease({}, (err, results) => {
|
||||
pipelinePlugins.verifyRelease({}, function (err, results) {
|
||||
tt.is(err.message, 'b')
|
||||
tt.same(results, [undefined, 'a', undefined])
|
||||
tt.end()
|
||||
@@ -66,18 +66,18 @@ test('plugin pipelines', (t) => {
|
||||
})
|
||||
})
|
||||
|
||||
test('normalize and load plugin', (t) => {
|
||||
t.test('load from string', (tt) => {
|
||||
const plugin = plugins.normalize('./dist/lib/plugin-noop')
|
||||
test('normalize and load plugin', function (t) {
|
||||
t.test('load from string', function (tt) {
|
||||
var plugin = plugins.normalize('./src/lib/plugin-noop')
|
||||
|
||||
tt.is(typeof plugin, 'function')
|
||||
|
||||
tt.end()
|
||||
})
|
||||
|
||||
t.test('load from object', (tt) => {
|
||||
const plugin = plugins.normalize({
|
||||
path: './dist/lib/plugin-noop'
|
||||
t.test('load from object', function (tt) {
|
||||
var plugin = plugins.normalize({
|
||||
path: './src/lib/plugin-noop'
|
||||
})
|
||||
|
||||
tt.is(typeof plugin, 'function')
|
||||
@@ -85,8 +85,8 @@ test('normalize and load plugin', (t) => {
|
||||
tt.end()
|
||||
})
|
||||
|
||||
t.test('load from object', (tt) => {
|
||||
const plugin = plugins.normalize(null, '../../dist/lib/plugin-noop')
|
||||
t.test('load from fallback', function (tt) {
|
||||
var plugin = plugins.normalize(null, '../../src/lib/plugin-noop')
|
||||
|
||||
tt.is(typeof plugin, 'function')
|
||||
|
||||
|
||||
+24
-20
@@ -1,20 +1,24 @@
|
||||
const { defaults } = require('lodash')
|
||||
const test = require('tap').test
|
||||
const proxyquire = require('proxyquire')
|
||||
var defaults = require('lodash').defaults
|
||||
var test = require('tap').test
|
||||
var proxyquire = require('proxyquire')
|
||||
|
||||
const post = proxyquire('../../dist/post', {
|
||||
var post = proxyquire('../../src/post', {
|
||||
'git-head': require('../mocks/git-head'),
|
||||
github: require('../mocks/github')
|
||||
})
|
||||
|
||||
const pkg = {
|
||||
var pkg = {
|
||||
version: '1.0.0',
|
||||
repository: {url: 'http://github.com/whats/up.git'}
|
||||
}
|
||||
|
||||
const plugins = {generateNotes: (pkg, cb) => cb(null, 'the log')}
|
||||
var plugins = {
|
||||
generateNotes: function (pkg, cb) {
|
||||
cb(null, 'the log')
|
||||
}
|
||||
}
|
||||
|
||||
const defaultRelease = {
|
||||
var defaultRelease = {
|
||||
owner: 'whats',
|
||||
repo: 'up',
|
||||
name: 'v1.0.0',
|
||||
@@ -23,13 +27,13 @@ const defaultRelease = {
|
||||
body: 'the log'
|
||||
}
|
||||
|
||||
test('full post run', (t) => {
|
||||
t.test('in debug mode w/o token', (tt) => {
|
||||
test('full post run', function (t) {
|
||||
t.test('in debug mode w/o token', function (tt) {
|
||||
post({
|
||||
options: {debug: true},
|
||||
pkg,
|
||||
plugins
|
||||
}, (err, published, release) => {
|
||||
pkg: pkg,
|
||||
plugins: plugins
|
||||
}, function (err, published, release) {
|
||||
tt.error(err)
|
||||
tt.is(published, false)
|
||||
tt.match(release, defaults({draft: true}, defaultRelease))
|
||||
@@ -38,12 +42,12 @@ test('full post run', (t) => {
|
||||
})
|
||||
})
|
||||
|
||||
t.test('in debug mode w/token', (tt) => {
|
||||
t.test('in debug mode w/token', function (tt) {
|
||||
post({
|
||||
options: {debug: true, githubToken: 'yo'},
|
||||
pkg,
|
||||
plugins
|
||||
}, (err, published, release) => {
|
||||
pkg: pkg,
|
||||
plugins: plugins
|
||||
}, function (err, published, release) {
|
||||
tt.error(err)
|
||||
tt.is(published, true)
|
||||
tt.match(release, defaults({draft: true}, defaultRelease))
|
||||
@@ -52,12 +56,12 @@ test('full post run', (t) => {
|
||||
})
|
||||
})
|
||||
|
||||
t.test('production', (tt) => {
|
||||
t.test('production', function (tt) {
|
||||
post({
|
||||
options: {githubToken: 'yo'},
|
||||
pkg,
|
||||
plugins
|
||||
}, (err, published, release) => {
|
||||
pkg: pkg,
|
||||
plugins: plugins
|
||||
}, function (err, published, release) {
|
||||
tt.error(err)
|
||||
tt.is(published, true)
|
||||
tt.match(release, defaultRelease)
|
||||
|
||||
+24
-20
@@ -1,55 +1,59 @@
|
||||
const test = require('tap').test
|
||||
const proxyquire = require('proxyquire')
|
||||
var test = require('tap').test
|
||||
var proxyquire = require('proxyquire')
|
||||
|
||||
require('../mocks/registry')
|
||||
const pre = proxyquire('../../dist/pre', {
|
||||
'./lib/commits': proxyquire('../../dist/lib/commits', {
|
||||
var pre = proxyquire('../../src/pre', {
|
||||
'./lib/commits': proxyquire('../../src/lib/commits', {
|
||||
'child_process': require('../mocks/child-process')
|
||||
})
|
||||
})
|
||||
|
||||
const versions = {
|
||||
var versions = {
|
||||
available: '1.0.0'
|
||||
}
|
||||
|
||||
const plugins = {
|
||||
verifyRelease: (release, cb) => cb(null, release),
|
||||
analyzeCommits: (commits, cb) => cb(null, 'major'),
|
||||
getLastRelease: ({ pkg }, cb) => {
|
||||
cb(null, {version: versions[pkg.name] || null, gitHead: 'HEAD'})
|
||||
var plugins = {
|
||||
verifyRelease: function (release, cb) {
|
||||
cb(null, release)
|
||||
},
|
||||
analyzeCommits: function (commits, cb) {
|
||||
cb(null, 'major')
|
||||
},
|
||||
getLastRelease: function (config, cb) {
|
||||
cb(null, {version: versions[config.pkg.name] || null, gitHead: 'HEAD'})
|
||||
}
|
||||
}
|
||||
|
||||
const npm = {
|
||||
var npm = {
|
||||
registry: 'http://registry.npmjs.org/',
|
||||
tag: 'latest'
|
||||
}
|
||||
|
||||
test('full pre run', (t) => {
|
||||
t.test('increase version', (tt) => {
|
||||
test('full pre run', function (t) {
|
||||
t.test('increase version', function (tt) {
|
||||
tt.plan(3)
|
||||
|
||||
pre({
|
||||
options: {branch: 'master'},
|
||||
npm,
|
||||
npm: npm,
|
||||
pkg: {name: 'available'},
|
||||
plugins
|
||||
}, (err, release) => {
|
||||
plugins: plugins
|
||||
}, function (err, release) {
|
||||
tt.error(err)
|
||||
tt.is(release.type, 'major')
|
||||
tt.is(release.version, '2.0.0')
|
||||
})
|
||||
})
|
||||
|
||||
t.test('increase version', (tt) => {
|
||||
t.test('increase version', function (tt) {
|
||||
tt.plan(3)
|
||||
|
||||
pre({
|
||||
options: {branch: 'master'},
|
||||
npm,
|
||||
npm: npm,
|
||||
pkg: {name: 'unavailable'},
|
||||
plugins
|
||||
}, (err, release) => {
|
||||
plugins: plugins
|
||||
}, function (err, release) {
|
||||
tt.error(err)
|
||||
tt.is(release.type, 'initial')
|
||||
tt.is(release.version, '1.0.0')
|
||||
|
||||
+24
-12
@@ -1,9 +1,9 @@
|
||||
const test = require('tap').test
|
||||
var test = require('tap').test
|
||||
|
||||
const type = require('../../dist/lib/type')
|
||||
var type = require('../../src/lib/type')
|
||||
|
||||
test('get type from commits', (t) => {
|
||||
t.test('get type from plugin', (tt) => {
|
||||
test('get type from commits', function (t) {
|
||||
t.test('get type from plugin', function (tt) {
|
||||
tt.plan(2)
|
||||
|
||||
type({
|
||||
@@ -12,33 +12,45 @@ test('get type from commits', (t) => {
|
||||
message: 'a'
|
||||
}],
|
||||
lastRelease: {version: '1.0.0'},
|
||||
plugins: {analyzeCommits: (config, cb) => cb(null, 'major')}
|
||||
}, (err, type) => {
|
||||
plugins: {
|
||||
analyzeCommits: function (config, cb) {
|
||||
cb(null, 'major')
|
||||
}
|
||||
}
|
||||
}, function (err, type) {
|
||||
tt.error(err)
|
||||
tt.is(type, 'major')
|
||||
})
|
||||
})
|
||||
|
||||
t.test('error when no changes', (tt) => {
|
||||
t.test('error when no changes', function (tt) {
|
||||
tt.plan(1)
|
||||
|
||||
type({
|
||||
commits: [],
|
||||
lastRelease: {},
|
||||
plugins: {analyzeCommits: (config, cb) => cb(null, null)}
|
||||
}, (err) => {
|
||||
plugins: {
|
||||
analyzeCommits: function (config, cb) {
|
||||
cb(null, null)
|
||||
}
|
||||
}
|
||||
}, function (err) {
|
||||
tt.is(err.code, 'ENOCHANGE')
|
||||
})
|
||||
})
|
||||
|
||||
t.test('initial version', (tt) => {
|
||||
t.test('initial version', function (tt) {
|
||||
tt.plan(2)
|
||||
|
||||
type({
|
||||
commits: [],
|
||||
lastRelease: {},
|
||||
plugins: {analyzeCommits: (config, cb) => cb(null, 'major')}
|
||||
}, (err, type) => {
|
||||
plugins: {
|
||||
analyzeCommits: function (config, cb) {
|
||||
cb(null, 'major')
|
||||
}
|
||||
}
|
||||
}, function (err, type) {
|
||||
tt.error(err)
|
||||
tt.is(type, 'initial')
|
||||
})
|
||||
|
||||
+10
-10
@@ -1,10 +1,10 @@
|
||||
const test = require('tap').test
|
||||
var test = require('tap').test
|
||||
|
||||
const verify = require('../../dist/lib/verify')
|
||||
var verify = require('../../src/lib/verify')
|
||||
|
||||
test('verify pkg, options and env', (t) => {
|
||||
t.test('dry run verification', (tt) => {
|
||||
const noErrors = verify({
|
||||
test('verify pkg, options and env', function (t) {
|
||||
t.test('dry run verification', function (tt) {
|
||||
var noErrors = verify({
|
||||
options: {debug: true},
|
||||
pkg: {
|
||||
name: 'package',
|
||||
@@ -16,7 +16,7 @@ test('verify pkg, options and env', (t) => {
|
||||
|
||||
tt.is(noErrors.length, 0)
|
||||
|
||||
const errors = verify({
|
||||
var errors = verify({
|
||||
options: {debug: true},
|
||||
pkg: {}
|
||||
})
|
||||
@@ -25,7 +25,7 @@ test('verify pkg, options and env', (t) => {
|
||||
tt.is(errors[0].code, 'ENOPKGNAME')
|
||||
tt.is(errors[1].code, 'ENOPKGREPO')
|
||||
|
||||
const errors2 = verify({
|
||||
var errors2 = verify({
|
||||
options: {debug: true},
|
||||
pkg: {
|
||||
name: 'package',
|
||||
@@ -41,8 +41,8 @@ test('verify pkg, options and env', (t) => {
|
||||
tt.end()
|
||||
})
|
||||
|
||||
t.test('publish verification', (tt) => {
|
||||
const noErrors = verify({
|
||||
t.test('publish verification', function (tt) {
|
||||
var noErrors = verify({
|
||||
env: {NPM_TOKEN: 'yo'},
|
||||
options: {githubToken: 'sup'},
|
||||
pkg: {
|
||||
@@ -55,7 +55,7 @@ test('verify pkg, options and env', (t) => {
|
||||
|
||||
tt.is(noErrors.length, 0)
|
||||
|
||||
const errors = verify({env: {}, options: {}, pkg: {}})
|
||||
var errors = verify({env: {}, options: {}, pkg: {}})
|
||||
|
||||
tt.is(errors.length, 4)
|
||||
tt.is(errors[0].code, 'ENOPKGNAME')
|
||||
|
||||
Reference in New Issue
Block a user