Generalize getCategoryInputOrThrow to arbitrary inputs

This commit is contained in:
Henry Mercer 2022-11-23 12:43:32 +00:00
parent daf4614f68
commit bff0be7364
6 changed files with 141 additions and 97 deletions

26
lib/workflow.test.js generated
View file

@ -355,8 +355,8 @@ function errorCodes(actual, expected) {
on: ["push"]
`)), []));
});
(0, ava_1.default)("tryGetCategoryInput returns category for simple workflow with category", (t) => {
t.is((0, workflow_1.tryGetCategoryInput)(yaml.load(`
(0, ava_1.default)("getCategoryInputOrThrow returns category for simple workflow with category", (t) => {
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
jobs:
analysis:
runs-on: ubuntu-latest
@ -368,8 +368,8 @@ function errorCodes(actual, expected) {
category: some-category
`), {}), "some-category");
});
(0, ava_1.default)("tryGetCategoryInput returns undefined for simple workflow without category", (t) => {
t.is((0, workflow_1.tryGetCategoryInput)(yaml.load(`
(0, ava_1.default)("getCategoryInputOrThrow returns undefined for simple workflow without category", (t) => {
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
jobs:
analysis:
runs-on: ubuntu-latest
@ -379,8 +379,8 @@ function errorCodes(actual, expected) {
- uses: github/codeql-action/analyze@v2
`), {}), undefined);
});
(0, ava_1.default)("tryGetCategoryInput finds category for workflow with language matrix", (t) => {
t.is((0, workflow_1.tryGetCategoryInput)(yaml.load(`
(0, ava_1.default)("getCategoryInputOrThrow finds category for workflow with language matrix", (t) => {
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
jobs:
analysis:
runs-on: ubuntu-latest
@ -397,8 +397,8 @@ function errorCodes(actual, expected) {
category: "/language:\${{ matrix.language }}"
`), { language: "javascript" }), "/language:javascript");
});
(0, ava_1.default)("tryGetCategoryInput throws error for workflow with dynamic category", (t) => {
t.throws(() => (0, workflow_1.tryGetCategoryInput)(yaml.load(`
(0, ava_1.default)("getCategoryInputOrThrow throws error for workflow with dynamic category", (t) => {
t.throws(() => (0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
jobs:
analysis:
steps:
@ -408,11 +408,12 @@ function errorCodes(actual, expected) {
with:
category: "\${{ github.workflow }}"
`), {}), {
message: "Could not get category input since it contained an unrecognized dynamic value.",
message: "Could not get category input to github/codeql-action/analyze since it contained " +
"an unrecognized dynamic value.",
});
});
(0, ava_1.default)("tryGetCategoryInput throws error for workflow with multiple categories", (t) => {
t.throws(() => (0, workflow_1.tryGetCategoryInput)(yaml.load(`
(0, ava_1.default)("getCategoryInputOrThrow throws error for workflow with multiple categories", (t) => {
t.throws(() => (0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
jobs:
analysis:
runs-on: ubuntu-latest
@ -426,7 +427,8 @@ function errorCodes(actual, expected) {
with:
category: another-category
`), {}), {
message: "Could not get category input since multiple categories were specified by the analysis step.",
message: "Could not get category input to github/codeql-action/analyze since there were multiple steps " +
"calling github/codeql-action/analyze with different values for category.",
});
});
//# sourceMappingURL=workflow.test.js.map