Skip to content

Commit

Permalink
fix: args values need to be string (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
d2lam authored and tkyi committed May 21, 2018
1 parent 643cc56 commit d8cc58a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class ExecutorQueue extends Executor {
return this.queueBreaker.runCommand('enqueue', this.buildQueue, 'start', [{
buildId,
jobId,
blockedBy
blockedBy: blockedBy.toString()
}]);
}

Expand All @@ -307,7 +307,7 @@ class ExecutorQueue extends Executor {
const numDeleted = await this.queueBreaker.runCommand('del', this.buildQueue, 'start', [{
buildId,
jobId,
blockedBy
blockedBy: blockedBy.toString()
}]);

if (numDeleted !== 0) {
Expand All @@ -319,7 +319,7 @@ class ExecutorQueue extends Executor {
return this.queueBreaker.runCommand('enqueue', this.buildQueue, 'stop', [{
buildId,
jobId,
blockedBy
blockedBy: blockedBy.toString()
}]);
}

Expand Down
2 changes: 1 addition & 1 deletion test/data/fullConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"container": "node:4",
"apiUri": "http://api.com",
"token": "asdf",
"blockedBy": [777]
"blockedBy": [777, 888]
}
22 changes: 16 additions & 6 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const partialTestConfig = {
jobId: testConfig.jobId,
blockedBy: testConfig.blockedBy
};
const partialTestConfigToString = Object.assign({}, partialTestConfig, {
blockedBy: testConfig.blockedBy.toString() });
const tokenGen = sinon.stub().returns('123456abc');
const testDelayedConfig = {
pipeline: testPipeline,
Expand Down Expand Up @@ -302,15 +304,23 @@ describe('index test', () => {
assert.calledOnce(queueMock.connect);
assert.calledWith(redisMock.hset, 'buildConfigs', testConfig.buildId,
JSON.stringify(testConfig));
assert.calledWith(queueMock.enqueue, 'builds', 'start', [partialTestConfig]);
assert.calledWith(queueMock.enqueue, 'builds', 'start', [partialTestConfigToString]);
}));

it('enqueues a build and caches the config', () => executor.start(testConfig).then(() => {
assert.calledOnce(queueMock.connect);
assert.calledWith(redisMock.hset, 'buildConfigs', testConfig.buildId,
JSON.stringify(testConfig));
assert.calledWith(queueMock.enqueue, 'builds', 'start', [partialTestConfigToString]);
}));

it('doesn\'t call connect if there\'s already a connection', () => {
queueMock.connection.connected = true;

return executor.start(testConfig).then(() => {
assert.notCalled(queueMock.connect);
assert.calledWith(queueMock.enqueue, 'builds', 'start', [partialTestConfig]);
assert.calledWith(queueMock.enqueue, 'builds', 'start',
[partialTestConfigToString]);
});
});
});
Expand All @@ -329,7 +339,7 @@ describe('index test', () => {
it('removes a start event from the queue and the cached buildconfig',
() => executor.stop(partialTestConfig).then(() => {
assert.calledOnce(queueMock.connect);
assert.calledWith(queueMock.del, 'builds', 'start', [partialTestConfig]);
assert.calledWith(queueMock.del, 'builds', 'start', [partialTestConfigToString]);
assert.calledWith(redisMock.hdel, 'buildConfigs', 8609);
assert.notCalled(queueMock.enqueue);
}));
Expand All @@ -339,8 +349,8 @@ describe('index test', () => {

return executor.stop(partialTestConfig).then(() => {
assert.calledOnce(queueMock.connect);
assert.calledWith(queueMock.del, 'builds', 'start', [partialTestConfig]);
assert.calledWith(queueMock.enqueue, 'builds', 'stop', [partialTestConfig]);
assert.calledWith(queueMock.del, 'builds', 'start', [partialTestConfigToString]);
assert.calledWith(queueMock.enqueue, 'builds', 'stop', [partialTestConfigToString]);
});
});

Expand All @@ -351,7 +361,7 @@ describe('index test', () => {
'beta.screwdriver.cd/executor': 'screwdriver-executor-k8s'
} })).then(() => {
assert.notCalled(queueMock.connect);
assert.calledWith(queueMock.del, 'builds', 'start', [partialTestConfig]);
assert.calledWith(queueMock.del, 'builds', 'start', [partialTestConfigToString]);
});
});
});
Expand Down

0 comments on commit d8cc58a

Please sign in to comment.