Skip to content

Commit

Permalink
fix: Fix log output and the test case for suspended users. (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdstar authored and tkyi committed Jul 26, 2018
1 parent 3565bbb commit 85c21bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ class GithubScm extends Scm {
// Suspended user
if (err.message.match(/suspend/i)) {
winston.info(
`User's account suspended for ${scmInfo.owner}/${scmInfo.repo}, ` +
`User's account suspended for ${config.scmUri}, ` +
'it will be removed from pipeline admins.');

return { admin: false, push: false, pull: false };
Expand Down
12 changes: 5 additions & 7 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ describe('index', function () {
it('catches and discards Github errors when it has a suspended user error message', () => {
const err = new Error('Sorry. Your account was suspended.');

githubMock.repos.get.yieldsAsync(err);
// in the lookupScmUri()
githubMock.repos.getById.yieldsAsync(err);

return scm.getPermissions(config)
.then((result) => {
Expand All @@ -412,19 +413,16 @@ describe('index', function () {
id: '359478'
});

assert.calledWith(githubMock.repos.get, {
owner: 'screwdriver-cd',
repo: 'models'
});

assert.calledWith(githubMock.authenticate, {
type: 'oauth',
token: config.token
});

assert.notCalled(githubMock.repos.get);

assert.calledWith(
winstonMock.info,
"User's account suspended for screwdriver-cd/models, " +
"User's account suspended for github.com:359478:master, " +
'it will be removed from pipeline admins.'
);
})
Expand Down

0 comments on commit 85c21bd

Please sign in to comment.