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

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2014-04-30 10:26:20 +0400
committerisaacs <i@izs.me>2014-04-30 23:21:20 +0400
commit608cd200735b142707e358d251c529375804d2ed (patch)
tree4204bcf6e435af4ef56950771253229feb423396 /test
parent44ed5943f152190808f804daf4b6940b1500bdd3 (diff)
cache: Handle 404s and other HTTP errors as errors
Fix #4982
Diffstat (limited to 'test')
-rw-r--r--test/tap/cache-add-unpublished.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/tap/cache-add-unpublished.js b/test/tap/cache-add-unpublished.js
new file mode 100644
index 000000000..e31321314
--- /dev/null
+++ b/test/tap/cache-add-unpublished.js
@@ -0,0 +1,61 @@
+var common = require('../common-tap.js')
+var test = require('tap').test
+
+var server
+
+var port = common.port
+var http = require("http")
+
+var doc = {
+ "_id": "superfoo",
+ "_rev": "5-d11adeec0fdfea6b96b120610d2bed71",
+ "name": "superfoo",
+ "time": {
+ "modified": "2014-02-18T18:35:02.930Z",
+ "created": "2014-02-18T18:34:08.437Z",
+ "1.1.0": "2014-02-18T18:34:08.437Z",
+ "unpublished": {
+ "name": "isaacs",
+ "time": "2014-04-30T18:26:45.584Z",
+ "tags": {
+ "latest": "1.1.0"
+ },
+ "maintainers": [
+ {
+ "name": "foo",
+ "email": "foo@foo.com"
+ }
+ ],
+ "description": "do lots a foo",
+ "versions": [
+ "1.1.0"
+ ]
+ }
+ },
+ "_attachments": {}
+}
+
+test("setup", function (t) {
+ server = http.createServer(function(req, res) {
+ res.end(JSON.stringify(doc))
+ })
+ server.listen(port, function() {
+ t.end()
+ })
+})
+
+test("cache add", function (t) {
+ common.npm(["cache", "add", "superfoo"], {}, function (er, c, so, se) {
+ if (er) throw er
+ t.ok(c)
+ t.equal(so, "")
+ t.similar(se, /404 Not Found: superfoo/)
+ t.end()
+ })
+})
+
+test("cleanup", function (t) {
+ server.close(function() {
+ t.end()
+ })
+})