Skip to content

Commit

Permalink
Fix specs for #966
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 27, 2022
1 parent cfae247 commit 39a318b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
17 changes: 14 additions & 3 deletions test/npm.js
Expand Up @@ -182,10 +182,21 @@ test('should throw if user is not authenticated', async t => {
exec.restore();
});

test('should throw if user is not a collaborator', async t => {
test('should throw if user is not a collaborator (v9)', async t => {
const npmClient = factory(npm);
const exec = sinon.stub(npmClient.shell, 'exec').resolves();
exec.withArgs('npm whoami').resolves('ada');
exec.withArgs('npm --version').resolves('9.2.0');
exec.withArgs('npm access list collaborators --json release-it').resolves(JSON.stringify({ john: ['write'] }));
await t.throwsAsync(runTasks(npmClient), { message: /^User ada is not a collaborator for release-it/ });
exec.restore();
});

test('should throw if user is not a collaborator (v8)', async t => {
const npmClient = factory(npm);
const exec = sinon.stub(npmClient.shell, 'exec').resolves();
exec.withArgs('npm whoami').resolves('ada');
exec.withArgs('npm --version').resolves('8.2.0');
exec.withArgs('npm access ls-collaborators release-it').resolves(JSON.stringify({ john: ['write'] }));
await t.throwsAsync(runTasks(npmClient), { message: /^User ada is not a collaborator for release-it/ });
exec.restore();
Expand Down Expand Up @@ -307,7 +318,7 @@ test('should publish to a different/scoped registry', async t => {
'npm ping --registry https://gitlab.com/api/v4/projects/my-scope%2Fmy-pkg/packages/npm/',
'npm whoami --registry https://gitlab.com/api/v4/projects/my-scope%2Fmy-pkg/packages/npm/',
'npm show @my-scope/my-pkg@latest version --registry https://gitlab.com/api/v4/projects/my-scope%2Fmy-pkg/packages/npm/',
'npm access ls-collaborators @my-scope/my-pkg --registry https://gitlab.com/api/v4/projects/my-scope%2Fmy-pkg/packages/npm/',
'npm --version',
'npm version 1.0.1 --no-git-tag-version',
'npm publish . --tag latest'
]);
Expand Down Expand Up @@ -341,7 +352,7 @@ test('should not publish when `npm version` fails', async t => {
'npm ping',
'npm whoami',
'npm show @my-scope/my-pkg@latest version',
'npm access ls-collaborators @my-scope/my-pkg',
'npm --version',
'npm version 1.0.1 --no-git-tag-version'
]);

Expand Down
7 changes: 5 additions & 2 deletions test/tasks.js
Expand Up @@ -128,7 +128,7 @@ test.serial('should use pkg.version (in sub dir) w/o tagging repo', async t => {
const { stdout } = sh.exec('git describe --tags --match=* --abbrev=0');
t.is(stdout.trim(), '1.0.0');
const npmArgs = getArgs(exec.args, 'npm');
t.is(npmArgs[4], 'npm version 1.3.0 --no-git-tag-version');
t.is(npmArgs[5], 'npm version 1.3.0 --no-git-tag-version');
exec.restore();
});

Expand Down Expand Up @@ -174,6 +174,7 @@ test.serial('should release all the things (basic)', async t => {
'npm ping',
'npm whoami',
`npm show ${pkgName}@latest version`,
'npm --version',
`npm access ls-collaborators ${pkgName}`,
'npm version 1.0.1 --no-git-tag-version',
'npm publish . --tag latest'
Expand Down Expand Up @@ -307,6 +308,7 @@ test.serial('should release all the things (pre-release, github, gitlab)', async
'npm ping',
'npm whoami',
`npm show ${pkgName}@latest version`,
'npm --version',
`npm access ls-collaborators ${pkgName}`,
'npm version 1.1.0-alpha.0 --no-git-tag-version',
'npm publish . --tag alpha'
Expand Down Expand Up @@ -346,6 +348,7 @@ test.serial('should publish pre-release without pre-id with different npm.tag',
'npm ping',
'npm whoami',
`npm show ${pkgName}@latest version`,
'npm --version',
`npm access ls-collaborators ${pkgName}`,
'npm version 2.0.0-0 --no-git-tag-version',
'npm publish . --tag next'
Expand Down Expand Up @@ -393,7 +396,7 @@ test.serial('should initially publish non-private scoped npm package privately',
await runTasks({}, container);

const npmArgs = getArgs(container.shell.exec.args, 'npm');
t.is(npmArgs[5], 'npm publish . --tag latest');
t.is(npmArgs[6], 'npm publish . --tag latest');
exec.restore();
});

Expand Down

0 comments on commit 39a318b

Please sign in to comment.