Commit 8a55f839 authored by Marc Mueller's avatar Marc Mueller
Browse files

Add test case for process exit

Co-authored-by: default avatarBethany <[email protected]>
parent 3884cace
Loading
Loading
Loading
Loading
+16
Changes for __tests__/restoreImpl.test.ts: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -449,3 +449,19 @@ test("restore with lookup-only set", async () => {
    );
    expect(failedMock).toHaveBeenCalledTimes(0);
});

test("restore failure with earlyExit should call process exit", async () => {
    testUtils.setInput(Inputs.Path, "node_modules");
    const failedMock = jest.spyOn(core, "setFailed");
    const restoreCacheMock = jest.spyOn(cache, "restoreCache");
    const processExitMock = jest.spyOn(process, "exit").mockImplementation();

    // call restoreImpl with `earlyExit` set to true
    await restoreImpl(new StateProvider(), true);

    expect(restoreCacheMock).toHaveBeenCalledTimes(0);
    expect(failedMock).toHaveBeenCalledWith(
        "Input required and not supplied: key"
    );
    expect(processExitMock).toHaveBeenCalledWith(1);
});