Skip to content

Commit

Permalink
fix(1415): models@v28.3.0 (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
wahapo committed Oct 13, 2020
1 parent 5b873d5 commit 776384e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -111,7 +111,7 @@
"screwdriver-executor-queue": "^3.0.0",
"screwdriver-executor-router": "^2.0.0",
"screwdriver-logger": "^1.0.1",
"screwdriver-models": "^28.0.0",
"screwdriver-models": "^28.3.0",
"screwdriver-notifications-email": "^2.0.0",
"screwdriver-notifications-slack": "^3.0.0",
"screwdriver-scm-base": "^7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/pipelines/create.js
Expand Up @@ -115,7 +115,7 @@ module.exports = () => ({

const results = await Promise.all([
pipeline.sync(),
pipeline.addWebhook(`${request.server.info.uri}/v4/webhooks`)
pipeline.addWebhooks(`${request.server.info.uri}/v4/webhooks`)
]);

const location = urlLib.format({
Expand Down
2 changes: 1 addition & 1 deletion plugins/pipelines/syncWebhooks.js
Expand Up @@ -51,7 +51,7 @@ module.exports = () => ({
}
})
// user has good permissions, add or update webhooks
.then(() => pipeline.addWebhook(`${request.server.info.uri}/v4/webhooks`))
.then(() => pipeline.addWebhooks(`${request.server.info.uri}/v4/webhooks`))
.then(() => h.response().code(204))
);
})
Expand Down
2 changes: 1 addition & 1 deletion plugins/pipelines/update.js
Expand Up @@ -140,7 +140,7 @@ module.exports = () => ({
.then(updatedPipeline =>
Promise.all([
updatedPipeline.sync(),
updatedPipeline.addWebhook(
updatedPipeline.addWebhooks(
`${request.server.info.uri}/v4/webhooks`
)
])
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/caches.test.js
Expand Up @@ -15,7 +15,7 @@ const decoratePipelineMock = pipeline => {
const mock = hoek.clone(pipeline);

mock.sync = sinon.stub();
mock.addWebhook = sinon.stub();
mock.addWebhooks = sinon.stub();
mock.syncPRs = sinon.stub();
mock.update = sinon.stub();
mock.toJson = sinon.stub().returns(pipeline);
Expand Down
40 changes: 20 additions & 20 deletions test/plugins/pipelines.test.js
Expand Up @@ -79,7 +79,7 @@ const decoratePipelineMock = pipeline => {
const mock = hoek.clone(pipeline);

mock.sync = sinon.stub();
mock.addWebhook = sinon.stub();
mock.addWebhooks = sinon.stub();
mock.syncPRs = sinon.stub();
mock.update = sinon.stub();
mock.toJson = sinon.stub().returns(pipeline);
Expand Down Expand Up @@ -1304,7 +1304,7 @@ describe('pipeline plugin test', () => {
});

it('returns 500 when model returns an error', () => {
pipelineMock.addWebhook.rejects(new Error('icantdothatdave'));
pipelineMock.addWebhooks.rejects(new Error('icantdothatdave'));

return server.inject(options).then(reply => {
assert.equal(reply.statusCode, 500);
Expand Down Expand Up @@ -1436,7 +1436,7 @@ describe('pipeline plugin test', () => {

pipelineMock = getPipelineMocks(testPipeline);
pipelineMock.sync.resolves(pipelineMock);
pipelineMock.addWebhook.resolves(null);
pipelineMock.addWebhooks.resolves(null);

pipelineFactoryMock.get.resolves(null);
pipelineFactoryMock.create.resolves(pipelineMock);
Expand Down Expand Up @@ -1653,7 +1653,7 @@ describe('pipeline plugin test', () => {
})
.resolves([getCollectionMock(testDefaultCollection)]);

pipelineMock.addWebhook.rejects(testError);
pipelineMock.addWebhooks.rejects(testError);

return server.inject(options).then(reply => {
assert.equal(reply.statusCode, 500);
Expand Down Expand Up @@ -1704,7 +1704,7 @@ describe('pipeline plugin test', () => {

pipelineMock = getPipelineMocks(testPipeline);
updatedPipelineMock = hoek.clone(pipelineMock);
updatedPipelineMock.addWebhook.resolves(null);
updatedPipelineMock.addWebhooks.resolves(null);

pipelineFactoryMock.get.withArgs({ id }).resolves(pipelineMock);
pipelineFactoryMock.get.withArgs({ scmUri }).resolves(null);
Expand All @@ -1719,7 +1719,7 @@ describe('pipeline plugin test', () => {
it('returns 200 and correct pipeline data', () =>
server.inject(options).then(reply => {
assert.calledOnce(pipelineMock.update);
assert.calledOnce(updatedPipelineMock.addWebhook);
assert.calledOnce(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 200);
}));

Expand All @@ -1733,7 +1733,7 @@ describe('pipeline plugin test', () => {

return server.inject(options).then(reply => {
assert.calledOnce(pipelineMock.update);
assert.calledOnce(updatedPipelineMock.addWebhook);
assert.calledOnce(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 200);
});
});
Expand Down Expand Up @@ -1790,7 +1790,7 @@ describe('pipeline plugin test', () => {
pipelineFactoryMock.get.withArgs({ id }).resolves(null);

return server.inject(options).then(reply => {
assert.notCalled(updatedPipelineMock.addWebhook);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 404);
});
});
Expand All @@ -1799,7 +1799,7 @@ describe('pipeline plugin test', () => {
pipelineMock.configPipelineId = 123;

return server.inject(options).then(reply => {
assert.notCalled(updatedPipelineMock.addWebhook);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 403);
});
});
Expand All @@ -1808,7 +1808,7 @@ describe('pipeline plugin test', () => {
userMock.getPermissions.withArgs(scmUri).resolves({ admin: false });

return server.inject(options).then(reply => {
assert.notCalled(updatedPipelineMock.addWebhook);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 403);
});
});
Expand All @@ -1817,7 +1817,7 @@ describe('pipeline plugin test', () => {
userMock.getPermissions.withArgs(oldScmUri).resolves({ admin: false });

return server.inject(options).then(reply => {
assert.notCalled(updatedPipelineMock.addWebhook);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 403);
});
});
Expand All @@ -1830,7 +1830,7 @@ describe('pipeline plugin test', () => {
// Only call once to get permissions on the new repo
assert.calledOnce(userMock.getPermissions);
assert.calledWith(userMock.getPermissions, scmUri);
assert.calledOnce(updatedPipelineMock.addWebhook);
assert.calledOnce(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 200);
});
});
Expand All @@ -1843,7 +1843,7 @@ describe('pipeline plugin test', () => {
// Only call once to get permissions on the new repo
assert.calledOnce(userMock.getPermissions);
assert.calledWith(userMock.getPermissions, scmUri);
assert.notCalled(updatedPipelineMock.addWebhook);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 403);
});
});
Expand All @@ -1857,7 +1857,7 @@ describe('pipeline plugin test', () => {
};

return server.inject(options).then(reply => {
assert.notCalled(updatedPipelineMock.addWebhook);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 401);
});
});
Expand All @@ -1867,7 +1867,7 @@ describe('pipeline plugin test', () => {

return server.inject(options).then(reply => {
assert.equal(reply.statusCode, 409);
assert.notCalled(updatedPipelineMock.addWebhook);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.strictEqual(reply.result.message, `Pipeline already exists with the ID: ${pipelineMock.id}`);
});
});
Expand All @@ -1878,7 +1878,7 @@ describe('pipeline plugin test', () => {
pipelineFactoryMock.get.withArgs({ id }).rejects(testError);

return server.inject(options).then(reply => {
assert.notCalled(updatedPipelineMock.addWebhook);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 500);
});
});
Expand All @@ -1889,7 +1889,7 @@ describe('pipeline plugin test', () => {
pipelineMock.update.rejects(testError);

return server.inject(options).then(reply => {
assert.notCalled(updatedPipelineMock.addWebhook);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 500);
});
});
Expand All @@ -1900,18 +1900,18 @@ describe('pipeline plugin test', () => {
pipelineMock.sync.rejects(testError);

return server.inject(options).then(reply => {
assert.calledOnce(updatedPipelineMock.addWebhook);
assert.calledOnce(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 500);
});
});

it('returns 500 when the pipeline model fails to add webhooks during create', () => {
const testError = new Error('pipelineModelAddWebhookError');

updatedPipelineMock.addWebhook.rejects(testError);
updatedPipelineMock.addWebhooks.rejects(testError);

return server.inject(options).then(reply => {
assert.calledOnce(updatedPipelineMock.addWebhook);
assert.calledOnce(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 500);
});
});
Expand Down

0 comments on commit 776384e

Please sign in to comment.