Skip to content

Commit

Permalink
fix: do not store state & archived to buildconfig (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
d2lam authored and jithine committed Sep 20, 2019
1 parent d46a16f commit 23c6e61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,12 @@ class ExecutorQueue extends Executor {
});

// Skip if job is disabled or archived
// Check if jobState & jobArchived exist first, for backward compatibility, TODO: remove later
if ((jobState && jobState !== 'ENABLED') || (jobArchived && jobArchived === true)) {

if (jobState === 'DISABLED' || jobArchived === true) {
return Promise.resolve();
}
delete config.jobState;
delete config.jobArchived;

const currentTime = new Date();
const origTime = new Date(currentTime.getTime());
Expand Down
8 changes: 6 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const partialTestConfigToString = Object.assign({}, partialTestConfig, {
const testAdmin = {
username: 'admin'
};
const buildTestConfig = Object.assign({}, testConfig);

delete buildTestConfig.jobState;
delete buildTestConfig.jobArchived;

const EventEmitter = require('events').EventEmitter;

Expand Down Expand Up @@ -419,7 +423,7 @@ describe('index test', () => {
return executor.start(testConfig).then(() => {
assert.calledTwice(queueMock.connect);
assert.calledWith(redisMock.hset, 'buildConfigs', buildId,
JSON.stringify(testConfig));
JSON.stringify(buildTestConfig));
assert.calledWith(queueMock.enqueue, 'builds', 'start',
[partialTestConfigToString]);
assert.calledOnce(buildMock.update);
Expand All @@ -432,7 +436,7 @@ describe('index test', () => {
it('enqueues a build and caches the config', () => executor.start(testConfig).then(() => {
assert.calledTwice(queueMock.connect);
assert.calledWith(redisMock.hset, 'buildConfigs', buildId,
JSON.stringify(testConfig));
JSON.stringify(buildTestConfig));
assert.calledWith(queueMock.enqueue, 'builds', 'start', [partialTestConfigToString]);
}));

Expand Down

0 comments on commit 23c6e61

Please sign in to comment.