Skip to content

Commit 9f7bf09

Browse files
committed
test(release): assert dispatch input pairs
1 parent 96b05c5 commit 9f7bf09

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

‎test/scripts/full-release-validation-at-sha.test.ts‎

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -401,20 +401,31 @@ describe("full-release-validation-at-sha", () => {
401401
),
402402
);
403403
const dispatch = ghCalls.find((args) => args[0] === "workflow" && args[1] === "run");
404-
expect(dispatch).toEqual(
405-
expect.arrayContaining([
406-
"--ref",
407-
workflowBranch,
408-
"-f",
409-
`ref=${targetBranch}`,
410-
"-f",
411-
`expected_sha=${fixture.targetSha}`,
412-
"-f",
413-
`target_context_ref=${fixture.releaseRef}`,
414-
"-f",
415-
"allow_unreleased_changelog=false",
416-
]),
417-
);
404+
expect(dispatch?.slice(0, 5)).toEqual([
405+
"workflow",
406+
"run",
407+
"full-release-validation.yml",
408+
"--ref",
409+
workflowBranch,
410+
]);
411+
const inputArgs = dispatch?.slice(5) ?? [];
412+
expect(inputArgs.length % 2).toBe(0);
413+
const dispatchInputs: Record<string, string> = {};
414+
for (let index = 0; index < inputArgs.length; index += 2) {
415+
expect(inputArgs[index]).toBe("-f");
416+
const assignment = inputArgs[index + 1];
417+
const separatorIndex = assignment?.indexOf("=") ?? -1;
418+
if (!assignment || separatorIndex <= 0) {
419+
throw new Error(`invalid workflow input assignment: ${String(assignment)}`);
420+
}
421+
dispatchInputs[assignment.slice(0, separatorIndex)] = assignment.slice(separatorIndex + 1);
422+
}
423+
expect(dispatchInputs).toMatchObject({
424+
ref: targetBranch,
425+
expected_sha: fixture.targetSha,
426+
target_context_ref: fixture.releaseRef,
427+
allow_unreleased_changelog: "false",
428+
});
418429
expect(ghCalls).toContainEqual(["api", "repos/openclaw/openclaw/actions/runs/123"]);
419430
expect(ghCalls.some((args) => args[0] === "graphql")).toBe(false);
420431
expect(ghCalls.some((args) => args[0] === "run" && args[1] === "watch")).toBe(false);

0 commit comments

Comments
 (0)