diff options
author | Rebecca Turner <me@re-becca.org> | 2015-09-25 02:44:02 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-09-25 02:44:02 +0300 |
commit | 4de3df1fa1c1c1f3793c31982c1e43c36fb02fd0 (patch) | |
tree | 21657fd379bbf0f7febb0f08ab31390e188f6303 /test | |
parent | ff47bc138e877835f1c0f419fea5f5672110678a (diff) |
test: Use unique package names in tests!
Diffstat (limited to 'test')
-rw-r--r-- | test/tap/404-private-registry.js | 11 | ||||
-rw-r--r-- | test/tap/add-named-update-protocol-port.js | 33 |
2 files changed, 26 insertions, 18 deletions
diff --git a/test/tap/404-private-registry.js b/test/tap/404-private-registry.js index 9e05f483e..698f5b861 100644 --- a/test/tap/404-private-registry.js +++ b/test/tap/404-private-registry.js @@ -1,21 +1,24 @@ var nock = require('nock') var test = require('tap').test +var path = require('path') var npm = require('../../') var addNamed = require('../../lib/cache/add-named') +var packageName = path.basename(__filename,'.js') + test('package names not mangled on error with non-root registry', function test404 (t) { nock('http://localhost:1337') - .get('/registry/foo') + .get('/registry/' + packageName) .reply(404, { error: 'not_found', reason: 'document not found' }) npm.load({registry: 'http://localhost:1337/registry', global: true}, function () { - addNamed('foo', '*', null, function checkError (err) { + addNamed(packageName, '*', null, function checkError (err) { t.ok(err, 'should error') - t.equal(err.message, '404 Not Found: foo', 'should have package name in error') - t.equal(err.pkgid, 'foo', 'err.pkgid should match package name') + t.equal(err.message, '404 Not Found: ' + packageName, 'should have package name in error') + t.equal(err.pkgid, packageName, 'err.pkgid should match package name') t.end() }) }) diff --git a/test/tap/add-named-update-protocol-port.js b/test/tap/add-named-update-protocol-port.js index efd7c90e8..52832db0c 100644 --- a/test/tap/add-named-update-protocol-port.js +++ b/test/tap/add-named-update-protocol-port.js @@ -1,30 +1,35 @@ +'use strict' +var path = require('path') var nock = require('nock') var test = require('tap').test var npm = require('../../') var addNamed = require('../../lib/cache/add-named') +var packageName = path.basename(__filename, '.js') + var fooPkg = { - name: 'foo', + name: packageName, versions: { '0.0.0': { - name: 'foo', + name: packageName, version: '0.0.0', dist: { - tarball: 'https://localhost:1338/registry/foo/-/foo-0.0.0.tgz', + tarball: 'https://localhost:1338/registry/' + packageName + '/-/' + packageName + '-0.0.0.tgz', shasum: '356a192b7913b04c54574d18c28d46e6395428ab' } } } } +var iPackageName = packageName + 'i' var fooiPkg = { - name: 'fooi', + name: iPackageName, versions: { '0.0.0': { - name: 'fooi', + name: iPackageName, version: '0.0.0', dist: { - tarball: 'http://127.0.0.1:1338/registry/fooi/-/fooi-0.0.0.tgz', + tarball: 'http://127.0.0.1:1338/registry/' + iPackageName + '/-/' + iPackageName + '-0.0.0.tgz', shasum: '356a192b7913b04c54574d18c28d46e6395428ab' } } @@ -33,19 +38,19 @@ var fooiPkg = { test('tarball paths should update port if updating protocol', function (t) { nock('http://localhost:1337/registry') - .get('/foo') + .get('/' + packageName) .reply(200, fooPkg) nock('http://localhost:1337/registry') - .get('/foo/-/foo-0.0.0.tgz') + .get('/' + packageName + '/-/' + packageName + '-0.0.0.tgz') .reply(200, '1') nock('http://localhost:1338/registry') - .get('/foo/-/foo-0.0.0.tgz') + .get('/' + packageName + '/-/' + packageName + '-0.0.0.tgz') .reply(404) npm.load({registry: 'http://localhost:1337/registry', global: true}, function () { - addNamed('foo', '0.0.0', null, function checkPath (err, pkg) { + addNamed(packageName, '0.0.0', null, function checkPath (err, pkg) { t.ifError(err, 'addNamed worked') t.end() }) @@ -55,19 +60,19 @@ test('tarball paths should update port if updating protocol', function (t) { test('tarball paths should NOT update if different hostname', function (t) { nock('http://localhost:1337/registry') - .get('/fooi') + .get('/' + iPackageName) .reply(200, fooiPkg) nock('http://127.0.0.1:1338/registry') - .get('/fooi/-/fooi-0.0.0.tgz') + .get('/' + iPackageName + '/-/' + iPackageName + '-0.0.0.tgz') .reply(200, '1') nock('http://127.0.0.1:1337/registry') - .get('/fooi/-/fooi-0.0.0.tgz') + .get('/' + iPackageName + '/-/' + iPackageName + '-0.0.0.tgz') .reply(404) npm.load({registry: 'http://localhost:1337/registry', global: true}, function () { - addNamed('fooi', '0.0.0', null, function checkPath (err, pkg) { + addNamed(iPackageName, '0.0.0', null, function checkPath (err, pkg) { t.ifError(err, 'addNamed worked') t.end() }) |