From 848f92adeb30e4dde30aaf8d6ddda13e479350d1 Mon Sep 17 00:00:00 2001 From: Amal Hussein Date: Fri, 8 Nov 2019 18:36:45 -0500 Subject: [PATCH] feat(docs): adding tests and updating docs to reflect changes in registry teams API. The default developers team can not longer be removed PR-URL: https://github.com/npm/cli/pull/457 Credit: @nomadtechie Close: #457 Reviewed-by: @claudiahdz --- docs/content/cli-commands/npm-team.md | 6 ++---- test/tap/team.js | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/content/cli-commands/npm-team.md b/docs/content/cli-commands/npm-team.md index 0f463f2985419..9a63b10c26f32 100755 --- a/docs/content/cli-commands/npm-team.md +++ b/docs/content/cli-commands/npm-team.md @@ -28,12 +28,10 @@ Used to manage teams in organizations, and change team memberships. Does not handle permissions for packages. Teams must always be fully qualified with the organization/scope they belong to -when operating on them, separated by a colon (`:`). That is, if you have a -`developers` team on a `foo` organization, you must always refer to that team as `foo:developers` in these commands. +when operating on them, separated by a colon (`:`). That is, if you have a `wombats` team in a `wisdom` organization, you must always refer to that team as `wisdom:wombats` in these commands. * create / destroy: - Create a new team, or destroy an existing one. - + Create a new team, or destroy an existing one. Note: You cannot remove the `developers` team, learn more. * add / rm: Add a user to an existing team, or remove a user from a team they belong to. diff --git a/test/tap/team.js b/test/tap/team.js index 939da45b77883..17acf82f4b231 100644 --- a/test/tap/team.js +++ b/test/tap/team.js @@ -88,6 +88,29 @@ test('team destroy', function (t) { }) }) +test('team destroy is not allowed for the default developers team', (t) => { + const teamData = { + name: 'developers', + scope_id: 1234, + created: '2015-07-23T18:07:49.959Z', + updated: '2015-07-23T18:07:49.959Z', + deleted: '2015-07-23T18:27:27.178Z' + } + server.delete('/-/team/myorg/' + teamData.name).reply(405, teamData) + common.npm([ + 'team', 'destroy', 'myorg:' + teamData.name, + '--registry', common.registry, + '--loglevel', 'silent', + '--json' + ], {}, function (err, code, stdout, stderr) { + t.ifError(err, 'npm team') + t.equal(code, 1, 'exited with code 1') + t.equal(stderr, '', 'no error output') + t.match(JSON.parse(stdout), {error: {code: 'E405'}}) + t.end() + }) +}) + test('team add', function (t) { var user = 'zkat' server.put('/-/team/myorg/myteam/user', JSON.stringify({