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

cache-add-unpublished.js « tap « test - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fe6807f19f987c1191b988e30e30e5b682606921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var common = require('../common-tap.js')
var test = require('tap').test

test('cache add', function (t) {
  setup(function (er, s) {
    if (er) {
      throw er
    }
    common.npm([
      'cache',
      'add',
      'superfoo',
      '--registry=http://localhost:1337/'
    ], {}, function (er, c, so, se) {
      if (er) throw er
      t.ok(c, 'got non-zero exit code')
      t.equal(so, '', 'nothing printed to stdout')
      t.similar(se, /404 Not Found: superfoo/, 'got expected error')
      s.close()
      t.end()
    })
  })
})

function setup (cb) {
  var s = require('http').createServer(function (req, res) {
    res.statusCode = 404
    res.end('{\"error\":\"not_found\"}\n')
  })
  s.listen(1337, function () {
    cb(null, s)
  })
}