Skip to content

Commit 8a55f83

Browse files
cdce8pbethanyj28
andcommitted
Add test case for process exit
Co-authored-by: Bethany <bethanyj28@users.noreply.github.com>
1 parent 3884cac commit 8a55f83

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎__tests__/restoreImpl.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,19 @@ test("restore with lookup-only set", async () => {
449449
);
450450
expect(failedMock).toHaveBeenCalledTimes(0);
451451
});
452+
453+
test("restore failure with earlyExit should call process exit", async () => {
454+
testUtils.setInput(Inputs.Path, "node_modules");
455+
const failedMock = jest.spyOn(core, "setFailed");
456+
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
457+
const processExitMock = jest.spyOn(process, "exit").mockImplementation();
458+
459+
// call restoreImpl with `earlyExit` set to true
460+
await restoreImpl(new StateProvider(), true);
461+
462+
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
463+
expect(failedMock).toHaveBeenCalledWith(
464+
"Input required and not supplied: key"
465+
);
466+
expect(processExitMock).toHaveBeenCalledWith(1);
467+
});

0 commit comments

Comments
 (0)