1 var mr = require("npm-registry-mock")
2 var test = require("tap").test
4 var common = require("../common-tap.js")
12 email : "jashkenas@gmail.com"
17 email : "forrest@npmjs.com"
22 email : "ben@npmjs.com"
25 function shrt (user) {
26 return user.name+" <"+user.email+">\n"
29 function mocks (server) {
30 server.get("/-/user/org.couchdb.user:othiym23")
31 .many().reply(200, othiym23)
34 server.get("/underscore")
35 .reply(200, {_id:"underscore",_rev:1,maintainers:[jashkenas]})
38 {_id:"underscore",_rev:1,maintainers:[jashkenas,othiym23]},
40 ).reply(200, {_id:"underscore",_rev:2,maintainers:[jashkenas,othiym23]})
43 server.get("/@xxx%2fscoped")
44 .reply(200, {_id:"@xxx/scoped",_rev:1,maintainers:[bcoe]})
46 "/@xxx%2fscoped/-rev/1",
47 {_id:"@xxx/scoped",_rev:1,maintainers:[bcoe,othiym23]},
49 ).reply(200, {_id:"@xxx/scoped",_rev:2,maintainers:[bcoe,othiym23]})
52 server.get("/underscore")
53 .reply(200, {_id:"underscore",_rev:2,maintainers:[jashkenas,othiym23]})
56 server.get("/underscore")
57 .reply(200, {_id:"underscore",_rev:2,maintainers:[jashkenas,othiym23]})
60 {_id:"underscore",_rev:2,maintainers:[jashkenas]},
62 ).reply(200, {_id:"underscore",_rev:3,maintainers:[jashkenas]})
65 test("setup", function (t) {
68 "--loglevel", "silent",
72 function (err, code) {
73 t.ifError(err, "npm cache clean ran without error")
74 t.notOk(code, "npm cache clean exited cleanly")
76 mr({ port : common.port, plugin : mocks }, function (err, s) {
84 test("npm owner add", function (t) {
87 "--loglevel", "silent",
88 "--registry", common.registry,
89 "owner", "add", "othiym23", "underscore"
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")
103 test("npm owner add (scoped)", function (t) {
106 "--loglevel", "silent",
107 "--registry", common.registry,
108 "owner", "add", "othiym23", "@xxx/scoped"
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")
122 test("npm owner ls", function (t) {
125 "--loglevel", "silent",
126 "--registry", common.registry,
127 "owner", "ls", "underscore"
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")
141 test("npm owner rm", function (t) {
144 "--loglevel", "silent",
145 "--registry", common.registry,
146 "owner", "rm", "othiym23", "underscore"
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")
160 test("cleanup", function (t) {