Improve test coverage

This commit is contained in:
Simon Engledew 2021-01-04 12:05:37 +00:00
parent 1511db33b3
commit 456cd431ff
No known key found for this signature in database
GPG key ID: 84302E7B02FE8BCE
3 changed files with 58 additions and 7 deletions

View file

@ -315,7 +315,7 @@ on:
`)); `));
t.deepEqual(errors, []); t.deepEqual(errors, []);
}); });
ava_1.default("validateWorkflow() should only report the first CheckoutWrongHead", (t) => { ava_1.default("validateWorkflow() should only report the current job's CheckoutWrongHead", (t) => {
process.env.GITHUB_JOB = "test"; process.env.GITHUB_JOB = "test";
const errors = actionsutil.validateWorkflow(yaml.safeLoad(` const errors = actionsutil.validateWorkflow(yaml.safeLoad(`
name: "CodeQL" name: "CodeQL"
@ -335,9 +335,32 @@ jobs:
- run: "git checkout HEAD^2" - run: "git checkout HEAD^2"
test3: test3:
steps: steps: []
- run: "git checkout HEAD^2"
`)); `));
t.deepEqual(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]); t.deepEqual(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]);
}); });
ava_1.default("validateWorkflow() should not report a different job's CheckoutWrongHead", (t) => {
process.env.GITHUB_JOB = "test3";
const errors = actionsutil.validateWorkflow(yaml.safeLoad(`
name: "CodeQL"
on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
jobs:
test:
steps:
- run: "git checkout HEAD^2"
test2:
steps:
- run: "git checkout HEAD^2"
test3:
steps: []
`));
t.deepEqual(errors, []);
});
//# sourceMappingURL=actions-util.test.js.map //# sourceMappingURL=actions-util.test.js.map

File diff suppressed because one or more lines are too long

View file

@ -435,7 +435,7 @@ on:
t.deepEqual(errors, []); t.deepEqual(errors, []);
}); });
test("validateWorkflow() should only report the first CheckoutWrongHead", (t) => { test("validateWorkflow() should only report the current job's CheckoutWrongHead", (t) => {
process.env.GITHUB_JOB = "test"; process.env.GITHUB_JOB = "test";
const errors = actionsutil.validateWorkflow( const errors = actionsutil.validateWorkflow(
@ -457,10 +457,38 @@ jobs:
- run: "git checkout HEAD^2" - run: "git checkout HEAD^2"
test3: test3:
steps: steps: []
- run: "git checkout HEAD^2"
`) `)
); );
t.deepEqual(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]); t.deepEqual(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]);
}); });
test("validateWorkflow() should not report a different job's CheckoutWrongHead", (t) => {
process.env.GITHUB_JOB = "test3";
const errors = actionsutil.validateWorkflow(
yaml.safeLoad(`
name: "CodeQL"
on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
jobs:
test:
steps:
- run: "git checkout HEAD^2"
test2:
steps:
- run: "git checkout HEAD^2"
test3:
steps: []
`)
);
t.deepEqual(errors, []);
});