Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLucas Theisen <ltheisen@mitre.org>2017-03-31 21:45:03 +0300
committerRebecca Turner <me@re-becca.org>2017-04-21 02:14:59 +0300
commitf08c663231099f7036eb82b92770806a3a79cdf1 (patch)
tree9e362735472ad7df6fff50d1c79c30c79940e53d /test
parentccbb94934d4f677f680c3e2284df3d0ae0e65758 (diff)
version: Add `--allow-same-version` option
Fixes: #11342 PR-URL: https://github.com/npm/npm/pull/16213 Credit: @lucastheisen Reviewed-By: @iarna
Diffstat (limited to 'test')
-rw-r--r--test/tap/version-allow-same-version.js66
-rw-r--r--test/tap/version-from-git.js2
2 files changed, 67 insertions, 1 deletions
diff --git a/test/tap/version-allow-same-version.js b/test/tap/version-allow-same-version.js
new file mode 100644
index 000000000..9900d28ba
--- /dev/null
+++ b/test/tap/version-allow-same-version.js
@@ -0,0 +1,66 @@
+var fs = require('graceful-fs')
+var path = require('path')
+
+var mkdirp = require('mkdirp')
+var osenv = require('osenv')
+var rimraf = require('rimraf')
+var test = require('tap').test
+
+var common = require('../common-tap.js')
+var npm = require('../../')
+var pkg = path.resolve(__dirname, 'version-allow-same-version')
+var cache = path.resolve(pkg, 'cache')
+var npmrc = path.resolve(pkg, './.npmrc')
+var configContents = 'sign-git-tag=false\n'
+
+test('npm version <semver> with same version without --allow-same-version', function (t) {
+ setup()
+ fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
+ author: 'Lucas Theisen',
+ name: 'version-allow-same-version',
+ version: '0.0.1',
+ description: 'Test for npm version without --allow-same-version'
+ }), 'utf8')
+ npm.load({cache: cache, 'allow-same-version': false, registry: common.registry}, function () {
+ var version = require('../../lib/version')
+ version(['0.0.1'], function (err) {
+ t.ok(err)
+ t.like(err.message, /Version not changed/)
+ t.end()
+ })
+ })
+})
+test('npm version <semver> with same version with --allow-same-version', function (t) {
+ setup()
+ fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
+ author: 'Lucas Theisen',
+ name: 'version-allow-same-version',
+ version: '0.0.1',
+ description: 'Test for npm version without --allow-same-version'
+ }), 'utf8')
+ npm.load({cache: cache, 'allow-same-version': true, registry: common.registry}, function () {
+ var version = require('../../lib/version')
+ version(['0.0.1'],
+ function (err) { t.ok(!err) },
+ function () { t.end() })
+ })
+})
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})
+
+function cleanup () {
+ // windows fix for locked files
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(pkg)
+}
+
+function setup () {
+ mkdirp.sync(pkg)
+ mkdirp.sync(path.join(pkg, 'node_modules'))
+ mkdirp.sync(cache)
+ fs.writeFileSync(npmrc, configContents, 'ascii')
+ process.chdir(pkg)
+}
+
diff --git a/test/tap/version-from-git.js b/test/tap/version-from-git.js
index 6f2c794ce..330b0604d 100644
--- a/test/tap/version-from-git.js
+++ b/test/tap/version-from-git.js
@@ -142,7 +142,7 @@ test('npm version from-git with an existing version', function (t) {
}
function checkVersion (er) {
- t.equal(er.message, 'Version not changed')
+ t.like(er.message, /Version not changed/)
t.done()
}
})