Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

Commit 2d4f909

Browse files
Michael Perrottemikemimik
Michael Perrotte
authored andcommittedMar 2, 2020
fix: update return value; add tests
1 parent c8e7bef commit 2d4f909

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
 

‎index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function setAccess (spec, access, opts) {
3838
body: { access },
3939
spec
4040
})
41-
}).then(res => res.body.resume() && true)
41+
}).then(res => true)
4242
}
4343

4444
cmd.grant = (spec, entity, permissions, opts) => {

‎test/index.js

+20
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ test('access public', t => {
1919
})
2020
})
2121

22+
test('access public - failure', t => {
23+
tnock(t, REG).post(
24+
'/-/package/%40foo%2Fbar/access', { access: 'public' }
25+
).reply(418)
26+
return access.public('@foo/bar', OPTS)
27+
.catch(err => {
28+
t.equals(err.statusCode, 418, 'fails with code from registry')
29+
})
30+
})
31+
2232
test('access restricted', t => {
2333
tnock(t, REG).post(
2434
'/-/package/%40foo%2Fbar/access', { access: 'restricted' }
@@ -28,6 +38,16 @@ test('access restricted', t => {
2838
})
2939
})
3040

41+
test('access restricted - failure', t => {
42+
tnock(t, REG).post(
43+
'/-/package/%40foo%2Fbar/access', { access: 'restricted' }
44+
).reply(418)
45+
return access.restricted('@foo/bar', OPTS)
46+
.catch(err => {
47+
t.equals(err.statusCode, 418, 'fails with code from registry')
48+
})
49+
})
50+
3151
test('access 2fa-required', t => {
3252
tnock(t, REG).post('/-/package/%40foo%2Fbar/access', {
3353
publish_requires_tfa: true

0 commit comments

Comments
 (0)
This repository has been archived.