Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
owners handles scoped packages (closes #6542)
Browse files Browse the repository at this point in the history
  • Loading branch information
othiym23 committed Nov 14, 2014
1 parent cd25973 commit eed9f61
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/owner.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function mutate (pkg, user, mutation, cb) {
_rev : data._rev,
maintainers : m
}
var dataPath = pkg + "/-rev/" + data._rev
var dataPath = pkg.replace("/", "%2f") + "/-rev/" + data._rev
mapToRegistry(dataPath, npm.config, function (er, uri, auth) {
if (er) return cb(er)

Expand Down
52 changes: 43 additions & 9 deletions test/tap/owner.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,47 @@ var othiym23 = {
email : "forrest@npmjs.com"
}

var bcoe = {
name : "bcoe",
email : "ben@npmjs.com"
}

function shrt (user) {
return user.name+" <"+user.email+">\n"
}

function mocks (server) {
// test 1
server.get("/-/user/org.couchdb.user:othiym23")
.reply(200, othiym23)
.many().reply(200, othiym23)

// test 1
server.get("/underscore")
.reply(200, {_id:1,_rev:1,maintainers:[jashkenas]})
.reply(200, {_id:"underscore",_rev:1,maintainers:[jashkenas]})
server.put(
"/underscore/-rev/1",
{_id: 1,_rev:1,maintainers:[jashkenas,othiym23]},
{_id:"underscore",_rev:1,maintainers:[jashkenas,othiym23]},
{}
).reply(200, {_id:1,_rev:2,maintainers:[jashkenas,othiym23]})
).reply(200, {_id:"underscore",_rev:2,maintainers:[jashkenas,othiym23]})

// test 2
server.get("/underscore")
.reply(200, {_id:1,_rev:2,maintainers:[jashkenas,othiym23]})
server.get("/@xxx%2fscoped")
.reply(200, {_id:"@xxx/scoped",_rev:1,maintainers:[bcoe]})
server.put(
"/@xxx%2fscoped/-rev/1",
{_id:"@xxx/scoped",_rev:1,maintainers:[bcoe,othiym23]},
{}
).reply(200, {_id:"@xxx/scoped",_rev:2,maintainers:[bcoe,othiym23]})

// test 3
server.get("/underscore")
.reply(200, {_id:"underscore",_rev:2,maintainers:[jashkenas,othiym23]})

// test 4
server.put(
"/underscore/-rev/2",
{_id:1,_rev:2,maintainers:[jashkenas]},
{_id:"underscore",_rev:2,maintainers:[jashkenas]},
{}
).reply(200, {_id:1,_rev:3,maintainers:[jashkenas]})
).reply(200, {_id:"underscore",_rev:3,maintainers:[jashkenas]})
}

test("setup", function (t) {
Expand Down Expand Up @@ -83,6 +98,25 @@ test("npm owner add", function (t) {
)
})

test("npm owner add (scoped)", function (t) {
common.npm(
[
"--loglevel", "silent",
"--registry", common.registry,
"owner", "add", "othiym23", "@xxx/scoped"
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, "npm owner add (scoped) ran without error")
t.notOk(code, "npm owner add (scoped) exited cleanly")
t.notOk(stderr, "npm owner add (scoped) ran silently")
t.equal(stdout, "+ othiym23 (@xxx/scoped)\n", "got expected scoped add output")

t.end()
}
)
})

test("npm owner ls", function (t) {
common.npm(
[
Expand Down

0 comments on commit eed9f61

Please sign in to comment.