mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 14:59:05 +00:00
test(ci): share single-head matching fixtures (#16899)
This commit is contained in:
1 parent
679fa590f6
commit
a60d5278ae
1 file changed
+21
-36
@@ -139,6 +139,12 @@ it("requires complete inventories, known mergeability, and immutable head identi
|
||||
|
||||
it("accepts event PR/head evidence for merge-SHA runs and refuses ambiguous branch identities", () => {
|
||||
const pull = validPull();
|
||||
const matchSingleHead = (candidate: PrCiWorkflowRun) =>
|
||||
matchRunToPullRequest({
|
||||
run: candidate,
|
||||
pull,
|
||||
identityCounts: new Map([["73\u0000feature", 1]]),
|
||||
});
|
||||
const associatedMergeRun = run({
|
||||
head_sha: mergeSha,
|
||||
pull_requests: [
|
||||
@@ -148,23 +154,18 @@ it("accepts event PR/head evidence for merge-SHA runs and refuses ambiguous bran
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(matchSingleHead(associatedMergeRun)).toEqual({
|
||||
kind: "match",
|
||||
basis: "event_pr_number_and_head_sha",
|
||||
});
|
||||
expect(
|
||||
matchRunToPullRequest({
|
||||
run: associatedMergeRun,
|
||||
pull,
|
||||
identityCounts: new Map([["73\u0000feature", 1]]),
|
||||
}),
|
||||
).toEqual({ kind: "match", basis: "event_pr_number_and_head_sha" });
|
||||
expect(
|
||||
matchRunToPullRequest({
|
||||
run: run({
|
||||
matchSingleHead(
|
||||
run({
|
||||
pull_requests: [
|
||||
{ number: pull.number!, head: { sha: "c".repeat(40) } },
|
||||
],
|
||||
}),
|
||||
pull,
|
||||
identityCounts: new Map([["73\u0000feature", 1]]),
|
||||
}).kind,
|
||||
).kind,
|
||||
).toBe("none");
|
||||
|
||||
const branchRun = run({ pull_requests: [] });
|
||||
@@ -176,31 +177,19 @@ it("accepts event PR/head evidence for merge-SHA runs and refuses ambiguous bran
|
||||
inventoryComplete: false,
|
||||
}).kind,
|
||||
).toBe("ambiguous");
|
||||
expect(
|
||||
matchRunToPullRequest({
|
||||
run: branchRun,
|
||||
pull,
|
||||
identityCounts: new Map([["73\u0000feature", 1]]),
|
||||
}),
|
||||
).toEqual({
|
||||
expect(matchSingleHead(branchRun)).toEqual({
|
||||
kind: "match",
|
||||
basis: "event_unique_head_ref_and_repository_id",
|
||||
});
|
||||
expect(
|
||||
matchRunToPullRequest({
|
||||
run: run({ head_sha: mergeSha, pull_requests: [] }),
|
||||
pull,
|
||||
identityCounts: new Map([["73\u0000feature", 1]]),
|
||||
}).kind,
|
||||
matchSingleHead(run({ head_sha: mergeSha, pull_requests: [] })).kind,
|
||||
).toBe("none");
|
||||
expect(
|
||||
matchRunToPullRequest({
|
||||
run: run({
|
||||
matchSingleHead(
|
||||
run({
|
||||
pull_requests: [{ number: pull.number!, head: { sha: headSha } }],
|
||||
}),
|
||||
pull,
|
||||
identityCounts: new Map([["73\u0000feature", 1]]),
|
||||
}).kind,
|
||||
).kind,
|
||||
).toBe("ambiguous");
|
||||
expect(
|
||||
matchRunToPullRequest({
|
||||
@@ -209,13 +198,9 @@ it("accepts event PR/head evidence for merge-SHA runs and refuses ambiguous bran
|
||||
identityCounts: new Map([["73\u0000feature", 2]]),
|
||||
}).kind,
|
||||
).toBe("ambiguous");
|
||||
expect(
|
||||
matchRunToPullRequest({
|
||||
run: run({ event: "workflow_dispatch" }),
|
||||
pull,
|
||||
identityCounts: new Map([["73\u0000feature", 1]]),
|
||||
}).kind,
|
||||
).toBe("none");
|
||||
expect(matchSingleHead(run({ event: "workflow_dispatch" })).kind).toBe(
|
||||
"none",
|
||||
);
|
||||
});
|
||||
|
||||
it("scans target-branch PRs through public gh GET requests and writes JSON and Markdown", async () => {
|
||||
|
||||
Reference in new issue
Block a user