• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var test = require('tap').test
2var path = require('path')
3var common = require('../common-tap.js')
4var mr = common.fakeRegistry.compat
5var server
6
7var packageName = path.basename(__filename, '.js')
8
9test('setup', function (t) {
10  mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
11    t.ifError(err, 'registry mocked successfully')
12    server = s
13    t.end()
14  })
15})
16
17test('package names not mangled on error with non-root registry', function (t) {
18  server.get('/' + packageName).reply(404, {})
19  common.npm(
20    [
21      '--registry=' + common.registry,
22      '--cache=' + common.cache,
23      'cache',
24      'add',
25      packageName + '@*'
26    ],
27    {},
28    function (er, code, stdout, stderr) {
29      t.ifError(er, 'correctly handled 404')
30      t.equal(code, 1, 'exited with error')
31      t.match(stderr, packageName, 'should have package name in error')
32      server.done()
33      server.close()
34      t.end()
35    }
36  )
37})
38