Skip to content

Commit

Permalink
feat(1710): support external AND
Browse files Browse the repository at this point in the history
  • Loading branch information
d2lam committed Oct 2, 2019
1 parent f190edd commit e2f2aea
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 3 additions & 1 deletion test/data/expected-external.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
{ "name": "main" },
{ "name": "foo" },
{ "name": "bar" },
{ "name": "sd@111:baz" },
{ "name": "~sd@1234:foo" }
],
"edges": [
{ "src": "~pr", "dest": "main" },
{ "src": "~commit", "dest": "main" },
{ "src": "main", "dest": "foo" },
{ "src": "~sd@1234:foo", "dest": "bar" },
{ "src": "foo", "dest": "bar" }
{ "src": "foo", "dest": "bar", "join": true },
{ "src": "sd@111:baz", "dest": "bar", "join": true }
]
}
2 changes: 1 addition & 1 deletion test/data/requires-workflow-exttrigger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"jobs": {
"main": { "requires": ["~pr", "~commit"] },
"foo": { "requires": ["main"] },
"bar": { "requires": ["foo", "~sd@1234:foo"] }
"bar": { "requires": ["foo", "sd@111:baz", "~sd@1234:foo"] }
}
}
5 changes: 5 additions & 0 deletions test/lib/getNextJobs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const assert = require('chai').assert;
const getNextJobs = require('../../lib/getNextJobs');
const WORKFLOW = require('../data/expected-output');
const EXTERNAL_WORKFLOW = require('../data/expected-external');

describe('getNextJobs', () => {
it('should throw if trigger not provided', () => {
Expand Down Expand Up @@ -59,6 +60,10 @@ describe('getNextJobs', () => {
}), []);
});

it('should figure out what jobs start next with parallel workflow with external', () => {
assert.deepEqual(getNextJobs(EXTERNAL_WORKFLOW, { trigger: 'sd@111:baz' }), ['bar']);
});

it('should figure out what jobs start next with parallel workflow', () => {
const parallelWorkflow = {
edges: [
Expand Down
18 changes: 18 additions & 0 deletions test/lib/getSrcForJoin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const assert = require('chai').assert;
const getSrcForJoin = require('../../lib/getSrcForJoin');
const WORKFLOW = require('../data/join-workflow');
const EXTERNAL_WORKFLOW = require('../data/expected-external');
const rewire = require('rewire');

const rewireGetSrcForJoin = rewire('../../lib/getSrcForJoin');
Expand All @@ -25,6 +26,16 @@ describe('getSrcForJoin', () => {
// return empty arry if it's not a join job
assert.deepEqual(getSrcForJoin(WORKFLOW, { jobName: 'bar' }), []);
});

it('should figure out what src for the job if it is a join and external job', () => {
// src nodes for join job
assert.deepEqual(getSrcForJoin(EXTERNAL_WORKFLOW, {
jobName: 'bar'
}), [
{ name: 'foo' },
{ name: 'sd@111:baz' }
]);
});
});

describe('isPR', () => {
Expand All @@ -49,6 +60,13 @@ describe('findJobs', () => {
new Set([{ name: 'main', id: 1 }, { name: 'other_main', id: 2 }]));
});

it('should find jobs when search job is joined job and is external', () => {
const destJobName = 'bar';

assert.deepEqual(findJobs(EXTERNAL_WORKFLOW, destJobName),
new Set([{ name: 'foo' }, { name: 'sd@111:baz' }]));
});

it('should not find jobs when search job is not joined job', () => {
const destJobName = 'bar';

Expand Down

0 comments on commit e2f2aea

Please sign in to comment.