-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): allow per-module specific command, close #102
- Loading branch information
Showing
11 changed files
with
265 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
exports['sorts by version 1'] = [ | ||
{ | ||
"name": "lodash", | ||
"version": "1.0.1", | ||
"from": "1.0.0", | ||
"works": true | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.0.2", | ||
"from": "1.0.0", | ||
"works": true | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.1.0", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.1.1", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.2.0", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.2.1", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.3.0", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.3.1", | ||
"from": "1.0.0", | ||
"works": false | ||
} | ||
] | ||
|
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,58 @@ | ||
const path = require('path') | ||
const chdir = require('chdir-promise') | ||
const nextUpdate = require('..') | ||
const execa = require('execa') | ||
const snapShot = require('snap-shot') | ||
const R = require('ramda') | ||
const TWO_MINUTES = 120000 | ||
|
||
const testFolder = path.join(__dirname, 'test-command-map') | ||
|
||
function prune () { | ||
return execa.shell('npm prune') | ||
} | ||
|
||
function install () { | ||
return execa.shell('npm install') | ||
} | ||
|
||
const flatVersionSort = R.compose( | ||
R.sortBy(R.prop('version')), | ||
R.flatten | ||
) | ||
|
||
it('sorts by version', () => { | ||
const results = [ | ||
[ { name: 'lodash', version: '1.0.1', from: '1.0.0', works: true }, | ||
{ name: 'lodash', version: '1.1.0', from: '1.0.0', works: false }, | ||
{ name: 'lodash', version: '1.1.1', from: '1.0.0', works: false }, | ||
{ name: 'lodash', version: '1.2.0', from: '1.0.0', works: false }, | ||
{ name: 'lodash', version: '1.2.1', from: '1.0.0', works: false }, | ||
{ name: 'lodash', version: '1.3.0', from: '1.0.0', works: false }, | ||
{ name: 'lodash', version: '1.3.1', from: '1.0.0', works: false }, | ||
{ name: 'lodash', version: '1.0.2', from: '1.0.0', works: true } ] | ||
] | ||
snapShot(flatVersionSort(results)) | ||
}) | ||
|
||
/* global describe, beforeEach, afterEach, it */ | ||
describe('per-module configured command', () => { | ||
beforeEach(function () { | ||
this.timeout(TWO_MINUTES) | ||
return chdir.to(testFolder) | ||
.then(prune) | ||
.then(install) | ||
}) | ||
|
||
afterEach(chdir.back) | ||
|
||
it('finds and uses module own test command', function () { | ||
this.timeout(TWO_MINUTES) | ||
const opts = { | ||
module: 'lodash', | ||
allow: 'minor' | ||
} | ||
return snapShot(nextUpdate(opts) | ||
.then(flatVersionSort)) | ||
}) | ||
}) |
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 @@ | ||
registry=http://registry.npmjs.org/ |
51 changes: 51 additions & 0 deletions
51
test/test-command-map/__snapshots__/command-spec.js.snap-shot
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,51 @@ | ||
exports['finds and uses module own test command 1'] = [ | ||
{ | ||
"name": "lodash", | ||
"version": "1.0.1", | ||
"from": "1.0.0", | ||
"works": true | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.0.2", | ||
"from": "1.0.0", | ||
"works": true | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.1.0", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.1.1", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.2.0", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.2.1", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.3.0", | ||
"from": "1.0.0", | ||
"works": false | ||
}, | ||
{ | ||
"name": "lodash", | ||
"version": "1.3.1", | ||
"from": "1.0.0", | ||
"works": false | ||
} | ||
] | ||
|
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,3 @@ | ||
const _ = require('lodash') | ||
console.log('lodash test version %s', _.VERSION) | ||
process.exit(_.VERSION.startsWith('1.0') ? 0 : 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "test-next-updater", | ||
"version": "0.0.1", | ||
"description": "Simple NPM module with dependencies for testing", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo 'no test'", | ||
"lodash-test": "node lodash-test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:bahmutov/test-next-updater.git" | ||
}, | ||
"keywords": [ | ||
"test", | ||
"versions", | ||
"updater" | ||
], | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"lodash": "1.0.0" | ||
}, | ||
"config": { | ||
"next-update": { | ||
"commands": { | ||
"lodash": "npm run lodash-test" | ||
} | ||
} | ||
} | ||
} |