Skip to content

Commit

Permalink
feat: Add state map changes for pending (#190)
Browse files Browse the repository at this point in the history
* add PENDING status in STATUS map

* Add state map changes for pending

* Remove unused statuses from scm map

* Remove unused statuses from scm map

* Add test cases for pending status
  • Loading branch information
ombharatiya authored Jun 29, 2021
1 parent 8cbd8ac commit febd284
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
10 changes: 3 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ const POLLING_INTERVAL = 0.2;
const POLLING_MAX_ATTEMPT = 10;
const STATE_MAP = {
SUCCESS: 'success',
RUNNING: 'pending',
QUEUED: 'pending',
PENDING: 'pending'
PENDING: 'pending',
FAILURE: 'failure'
};
const DESCRIPTION_MAP = {
SUCCESS: 'Everything looks good!',
FAILURE: 'Did not work as expected.',
ABORTED: 'Aborted mid-flight',
RUNNING: 'Testing your code...',
QUEUED: 'Looking for a place to park...',
PENDING: 'Looks good but incomplete.'
PENDING: 'Parked it as Pending...'
};
const PERMITTED_RELEASE_EVENT = [
'published'
Expand Down
36 changes: 36 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,42 @@ describe('index', function () {
})
);

it('promises to update commit status on pending', () => {
config.buildStatus = 'PENDING';

return scm.updateCommitStatus(config)
.then((result) => {
assert.deepEqual(result, data);

assert.calledWith(githubMock.request, 'GET /repositories/:id',
{ id: '14052' }
);
assert.calledWith(githubMock.repos.createCommitStatus, {
owner: 'screwdriver-cd',
repo: 'models',
sha: config.sha,
state: 'pending',
description: 'Parked it as Pending...',
context: 'Screwdriver/675/main',
target_url: 'https://foo.bar'
});
});
});

it('returns an error when update commit status to queued', () => {
const errMsg = '"buildStatus" must be one of [PENDING, SUCCESS, FAILURE]';

config.buildStatus = 'QUEUED';

return scm.updateCommitStatus(config)
.then(() => {
assert.fail('This should not fail the test');
})
.catch((error) => {
assert.strictEqual(error.message, errMsg);
});
});

it('promises to update commit status on success with custom context', () => {
config.context = 'findbugs';
config.description = '923 issues found. Previous count: 914 issues.';
Expand Down

0 comments on commit febd284

Please sign in to comment.