@@ -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 ( / G H _ A W _ R U N _ U R L / ) ;
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 ( / C a n n o t p a r s e r u n I D / ) ;
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 ( / F a i l e d t o d o w n l o a d a g e n t a r t i f a c t / ) ;
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