Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/eventFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ class EventFactory extends BaseFactory {
return p.sync(configPipelineSha, chainPR);
}

return p.sync(config.sha, chainPR);
return p.sync(sha, chainPR);
}

// for child pipelines, get config pipeline sha and sync with that
Expand All @@ -836,7 +836,11 @@ class EventFactory extends BaseFactory {
}

if (startFrom && startFrom.match(PR_CLOSED_TRIGGER)) {
return p.sync(config.sha, chainPR);
return p.sync(sha, chainPR);
}

if (sha && modelConfig.type === 'pipeline') {
return p.sync(sha, chainPR);
}

return p.sync(null, chainPR);
Expand Down
32 changes: 32 additions & 0 deletions test/lib/eventFactory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2490,6 +2490,7 @@ describe('Event Factory', () => {
config.configPipelineSha = 'configpipelinesha';
config.sha = 'configsha';
config.prRef = 'branch';
config.type = 'pr';
config.prNum = 20;

return eventFactory.create(config).then(model => {
Expand Down Expand Up @@ -3094,6 +3095,15 @@ describe('Event Factory', () => {
});
});

it('should create using latest sha if config does not have target sha', () => {
config.sha = null;

return eventFactory.create(config).then(model => {
assert.calledWith(pipelineMock.sync, null);
assert.instanceOf(model, Event);
});
});

it('should create using parentEvent workflowGraph and job configs', () => {
config.parentEventId = 222;
config.workflowGraph = {
Expand All @@ -3117,6 +3127,28 @@ describe('Event Factory', () => {
});
});

it('should create using parentEvent workflowGraph and job configs on fresh run', () => {
const expectedWorkflowGraph = {
nodes: [{ name: '~commit' }, { name: 'testJob' }],
edges: [{ src: '~commit', dest: 'testJob' }]
};

expected.workflowGraph = expectedWorkflowGraph;
syncedPipelineMock.workflowGraph = expectedWorkflowGraph;

return eventFactory.create(config).then(model => {
assert.calledWith(pipelineMock.sync, config.sha);
assert.instanceOf(model, Event);
Object.keys(expected).forEach(key => {
if (key === 'workflowGraph') {
assert.deepEqual(model[key], expected[key]);
} else if (key === 'parentEventId') {
assert.deepEqual(model[key], 222);
}
});
});
});

it('should have parameters if create with parameters', () => {
const pipelineWithParameter = {
parameters: {
Expand Down
5 changes: 4 additions & 1 deletion test/lib/token.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ describe('Token Model', () => {
id: 6789,
name: 'Mobile client auth token',
description: 'For the mobile app',
lastUsed: '2017-05-10T01:49:59.327Z'
lastUsed: '2017-05-10T01:49:59.327Z',
issuerId: undefined,
expiresAt: undefined,
options: undefined
Comment on lines +121 to +124

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

};
const value = 'tokenValue';

Expand Down