remove consts MismatchedBranches and MissingPushHook
This commit is contained in:
parent
95cfca769b
commit
edb138ff88
6 changed files with 4 additions and 268 deletions
|
|
@ -34,12 +34,6 @@ test("getWorkflowErrors() when on.push is an array missing pull_request", (t) =>
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.push is an array missing push", (t) => {
|
||||
const errors = getWorkflowErrors({ on: ["pull_request"] });
|
||||
|
||||
t.deepEqual(...errorCodes(errors, [WorkflowErrors.MissingPushHook]));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.push is valid", (t) => {
|
||||
const errors = getWorkflowErrors({
|
||||
on: ["push", "pull_request"],
|
||||
|
|
@ -64,14 +58,6 @@ test("getWorkflowErrors() when on.push is a correct object", (t) => {
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.pull_requests is a string", (t) => {
|
||||
const errors = getWorkflowErrors({
|
||||
on: { push: { branches: ["main"] }, pull_request: { branches: "*" } },
|
||||
});
|
||||
|
||||
t.deepEqual(...errorCodes(errors, [WorkflowErrors.MismatchedBranches]));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.pull_requests is a string and correct", (t) => {
|
||||
const errors = getWorkflowErrors({
|
||||
on: { push: { branches: "*" }, pull_request: { branches: "*" } },
|
||||
|
|
@ -92,17 +78,6 @@ test("getWorkflowErrors() when on.push is correct with empty objects", (t) => {
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.push is mismatched", (t) => {
|
||||
const errors = getWorkflowErrors({
|
||||
on: {
|
||||
push: { branches: ["main"] },
|
||||
pull_request: { branches: ["feature"] },
|
||||
},
|
||||
});
|
||||
|
||||
t.deepEqual(...errorCodes(errors, [WorkflowErrors.MismatchedBranches]));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.push is not mismatched", (t) => {
|
||||
const errors = getWorkflowErrors({
|
||||
on: {
|
||||
|
|
@ -114,17 +89,6 @@ test("getWorkflowErrors() when on.push is not mismatched", (t) => {
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.push is mismatched for pull_request", (t) => {
|
||||
const errors = getWorkflowErrors({
|
||||
on: {
|
||||
push: { branches: ["main"] },
|
||||
pull_request: { branches: ["main", "feature"] },
|
||||
},
|
||||
});
|
||||
|
||||
t.deepEqual(...errorCodes(errors, [WorkflowErrors.MismatchedBranches]));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
t.deepEqual(
|
||||
...errorCodes(
|
||||
|
|
@ -251,20 +215,6 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
|||
);
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.pull_request for every branch but push specifies branches", (t) => {
|
||||
const errors = getWorkflowErrors(
|
||||
yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
pull_request:
|
||||
`) as Workflow
|
||||
);
|
||||
|
||||
t.deepEqual(...errorCodes(errors, [WorkflowErrors.MismatchedBranches]));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.pull_request for wildcard branches", (t) => {
|
||||
const errors = getWorkflowErrors({
|
||||
on: {
|
||||
|
|
@ -276,17 +226,6 @@ test("getWorkflowErrors() when on.pull_request for wildcard branches", (t) => {
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when on.pull_request for mismatched wildcard branches", (t) => {
|
||||
const errors = getWorkflowErrors({
|
||||
on: {
|
||||
push: { branches: ["feature/moose"] },
|
||||
pull_request: { branches: "feature/*" },
|
||||
},
|
||||
});
|
||||
|
||||
t.deepEqual(...errorCodes(errors, [WorkflowErrors.MismatchedBranches]));
|
||||
});
|
||||
|
||||
test("getWorkflowErrors() when HEAD^2 is checked out", (t) => {
|
||||
process.env.GITHUB_JOB = "test";
|
||||
|
||||
|
|
@ -303,14 +242,6 @@ test("formatWorkflowErrors() when there is one error", (t) => {
|
|||
t.true(message.startsWith("1 issue was detected with this workflow:"));
|
||||
});
|
||||
|
||||
test("formatWorkflowErrors() when there are multiple errors", (t) => {
|
||||
const message = formatWorkflowErrors([
|
||||
WorkflowErrors.CheckoutWrongHead,
|
||||
WorkflowErrors.MismatchedBranches,
|
||||
]);
|
||||
t.true(message.startsWith("2 issues were detected with this workflow:"));
|
||||
});
|
||||
|
||||
test("formatWorkflowCause() with no errors", (t) => {
|
||||
const message = formatWorkflowCause([]);
|
||||
|
||||
|
|
@ -320,10 +251,9 @@ test("formatWorkflowCause() with no errors", (t) => {
|
|||
test("formatWorkflowCause()", (t) => {
|
||||
const message = formatWorkflowCause([
|
||||
WorkflowErrors.CheckoutWrongHead,
|
||||
WorkflowErrors.MismatchedBranches,
|
||||
]);
|
||||
|
||||
t.deepEqual(message, "CheckoutWrongHead,MismatchedBranches");
|
||||
t.deepEqual(message, "CheckoutWrongHead");
|
||||
t.deepEqual(formatWorkflowCause([]), undefined);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue