diff options
Diffstat (limited to 'deps/npm/test/tap/404-private-registry-scoped.js')
-rw-r--r-- | deps/npm/test/tap/404-private-registry-scoped.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/deps/npm/test/tap/404-private-registry-scoped.js b/deps/npm/test/tap/404-private-registry-scoped.js index 84251b113c..0f0cbc4ec7 100644 --- a/deps/npm/test/tap/404-private-registry-scoped.js +++ b/deps/npm/test/tap/404-private-registry-scoped.js @@ -1,9 +1,24 @@ var test = require('tap').test +var path = require('path') +var mkdirp = require('mkdirp') +var rimraf = require('rimraf') var common = require('../common-tap.js') var mr = require('npm-registry-mock') var server +var testdir = path.join(__dirname, path.basename(__filename, '.js')) + +function setup () { + cleanup() + mkdirp.sync(testdir) +} + +function cleanup () { + rimraf.sync(testdir) +} + test('setup', function (t) { + setup() mr({port: common.port, throwOnUnmatched: true}, function (err, s) { t.ifError(err, 'registry mocked successfully') server = s @@ -12,8 +27,11 @@ test('setup', function (t) { }) test('scoped package names not mangled on error with non-root registry', function (t) { + server.get('/@scope%2ffoo').reply(404, {}) common.npm( [ + '--registry=' + common.registry, + '--cache=' + testdir, 'cache', 'add', '@scope/foo@*', @@ -23,16 +41,17 @@ test('scoped package names not mangled on error with non-root registry', functio function (er, code, stdout, stderr) { t.ifError(er, 'correctly handled 404') t.equal(code, 1, 'exited with error') - t.match(stderr, /404 Not found/, 'should notify the sort of error as a 404') + t.match(stderr, /E404/, 'should notify the sort of error as a 404') t.match(stderr, /@scope\/foo/, 'should have package name in error') + server.done() t.end() } ) }) test('cleanup', function (t) { - t.pass('cleaned up') - server.done() server.close() + cleanup() + t.pass('cleaned up') t.end() }) |