Skip to content

Commit a22ff15

Browse files
jsweep: clean apply_safe_outputs_replay.cjs (#25982)
1 parent 86b9ddd commit a22ff15

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

actions/setup/js/apply_safe_outputs_replay.test.cjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,33 @@ describe("apply_safe_outputs_replay", () => {
256256
});
257257
});
258258

259+
describe("main", () => {
260+
it("calls setFailed when GH_AW_RUN_URL is not set", async () => {
261+
const { main } = await import("./apply_safe_outputs_replay.cjs");
262+
delete process.env.GH_AW_RUN_URL;
263+
await main();
264+
expect(global.core.setFailed, "should call setFailed when no run URL").toHaveBeenCalledOnce();
265+
expect(global.core.setFailed.mock.calls[0][0], "should mention GH_AW_RUN_URL").toMatch(/GH_AW_RUN_URL/);
266+
});
267+
268+
it("calls setFailed for an invalid GH_AW_RUN_URL", async () => {
269+
const { main } = await import("./apply_safe_outputs_replay.cjs");
270+
process.env.GH_AW_RUN_URL = "not-a-valid-run-url";
271+
await main();
272+
expect(global.core.setFailed, "should call setFailed for unparseable URL").toHaveBeenCalledOnce();
273+
expect(global.core.setFailed.mock.calls[0][0], "should describe the parse error").toMatch(/Cannot parse run ID/);
274+
});
275+
276+
it("calls setFailed when exec fails to download the artifact", async () => {
277+
const { main } = await import("./apply_safe_outputs_replay.cjs");
278+
process.env.GH_AW_RUN_URL = "23560193313";
279+
global.exec.exec = vi.fn().mockResolvedValue(1); // non-zero exit code
280+
await main();
281+
expect(global.core.setFailed, "should call setFailed on download failure").toHaveBeenCalledOnce();
282+
expect(global.core.setFailed.mock.calls[0][0], "error should mention ERR_SYSTEM").toMatch(/Failed to download agent artifact/);
283+
});
284+
});
285+
259286
describe("parseRunUrl (additional edge cases)", () => {
260287
it("throws for null input", async () => {
261288
const { parseRunUrl } = await import("./apply_safe_outputs_replay.cjs");

0 commit comments

Comments
 (0)