diff options
Diffstat (limited to 'deps/npm/test/tap/cache-add-unpublished.js')
-rw-r--r-- | deps/npm/test/tap/cache-add-unpublished.js | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/deps/npm/test/tap/cache-add-unpublished.js b/deps/npm/test/tap/cache-add-unpublished.js index 46f0db232..fe26929fc 100644 --- a/deps/npm/test/tap/cache-add-unpublished.js +++ b/deps/npm/test/tap/cache-add-unpublished.js @@ -1,12 +1,34 @@ var common = require("../common-tap.js") var test = require("tap").test +var mr = require("npm-registry-mock") test("cache add", function (t) { - common.npm(["cache", "add", "superfoo"], {}, 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") - t.end() + 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) + }) +} |