]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/owner.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / owner.js
1 var mr = require("npm-registry-mock")
2 var test = require("tap").test
3
4 var common = require("../common-tap.js")
5
6 var server
7
8 var EXEC_OPTS = {}
9
10 var jashkenas = {
11   name  : "jashkenas",
12   email : "jashkenas@gmail.com"
13 }
14
15 var othiym23 = {
16   name  : "othiym23",
17   email : "forrest@npmjs.com"
18 }
19
20 var bcoe = {
21   name  : "bcoe",
22   email : "ben@npmjs.com"
23 }
24
25 function shrt (user) {
26   return user.name+" <"+user.email+">\n"
27 }
28
29 function mocks (server) {
30   server.get("/-/user/org.couchdb.user:othiym23")
31     .many().reply(200, othiym23)
32
33   // test 1
34   server.get("/underscore")
35     .reply(200, {_id:"underscore",_rev:1,maintainers:[jashkenas]})
36   server.put(
37     "/underscore/-rev/1",
38     {_id:"underscore",_rev:1,maintainers:[jashkenas,othiym23]},
39     {}
40   ).reply(200, {_id:"underscore",_rev:2,maintainers:[jashkenas,othiym23]})
41
42   // test 2
43   server.get("/@xxx%2fscoped")
44     .reply(200, {_id:"@xxx/scoped",_rev:1,maintainers:[bcoe]})
45   server.put(
46     "/@xxx%2fscoped/-rev/1",
47     {_id:"@xxx/scoped",_rev:1,maintainers:[bcoe,othiym23]},
48     {}
49   ).reply(200, {_id:"@xxx/scoped",_rev:2,maintainers:[bcoe,othiym23]})
50
51   // test 3
52   server.get("/underscore")
53     .reply(200, {_id:"underscore",_rev:2,maintainers:[jashkenas,othiym23]})
54
55   // test 4
56   server.get("/underscore")
57     .reply(200, {_id:"underscore",_rev:2,maintainers:[jashkenas,othiym23]})
58   server.put(
59     "/underscore/-rev/2",
60     {_id:"underscore",_rev:2,maintainers:[jashkenas]},
61     {}
62   ).reply(200, {_id:"underscore",_rev:3,maintainers:[jashkenas]})
63 }
64
65 test("setup", function (t) {
66   common.npm(
67     [
68       "--loglevel", "silent",
69       "cache", "clean"
70     ],
71     EXEC_OPTS,
72     function (err, code) {
73       t.ifError(err,  "npm cache clean ran without error")
74       t.notOk(code,   "npm cache clean exited cleanly")
75
76       mr({ port : common.port, plugin : mocks }, function (err, s) {
77         server = s
78         t.end()
79       })
80     }
81   )
82 })
83
84 test("npm owner add", function (t) {
85   common.npm(
86     [
87       "--loglevel", "silent",
88       "--registry", common.registry,
89       "owner", "add", "othiym23", "underscore"
90     ],
91     EXEC_OPTS,
92     function (err, code, stdout, stderr) {
93       t.ifError(err,  "npm owner add ran without error")
94       t.notOk(code,   "npm owner add exited cleanly")
95       t.notOk(stderr, "npm owner add ran silently")
96       t.equal(stdout, "+ othiym23 (underscore)\n", "got expected add output")
97
98       t.end()
99     }
100   )
101 })
102
103 test("npm owner add (scoped)", function (t) {
104   common.npm(
105     [
106       "--loglevel", "silent",
107       "--registry", common.registry,
108       "owner", "add", "othiym23", "@xxx/scoped"
109     ],
110     EXEC_OPTS,
111     function (err, code, stdout, stderr) {
112       t.ifError(err,  "npm owner add (scoped) ran without error")
113       t.notOk(code,   "npm owner add (scoped) exited cleanly")
114       t.notOk(stderr, "npm owner add (scoped) ran silently")
115       t.equal(stdout, "+ othiym23 (@xxx/scoped)\n", "got expected scoped add output")
116
117       t.end()
118     }
119   )
120 })
121
122 test("npm owner ls", function (t) {
123   common.npm(
124     [
125       "--loglevel", "silent",
126       "--registry", common.registry,
127       "owner", "ls", "underscore"
128     ],
129     EXEC_OPTS,
130     function (err, code, stdout, stderr) {
131       t.ifError(err,  "npm owner ls ran without error")
132       t.notOk(code,   "npm owner ls exited cleanly")
133       t.notOk(stderr, "npm owner ls ran silently")
134       t.equal(stdout, shrt(jashkenas)+shrt(othiym23), "got expected ls output")
135
136       t.end()
137     }
138   )
139 })
140
141 test("npm owner rm", function (t) {
142   common.npm(
143     [
144       "--loglevel", "silent",
145       "--registry", common.registry,
146       "owner", "rm", "othiym23", "underscore"
147     ],
148     EXEC_OPTS,
149     function (err, code, stdout, stderr) {
150       t.ifError(err,  "npm owner rm ran without error")
151       t.notOk(code,   "npm owner rm exited cleanly")
152       t.notOk(stderr, "npm owner rm ran silently")
153       t.equal(stdout, "- othiym23 (underscore)\n", "got expected rm output")
154
155       t.end()
156     }
157   )
158 })
159
160 test("cleanup", function (t) {
161   server.close()
162   t.end()
163 })