|
|
@ -404,3 +404,48 @@ test("restore with cache found for restore key", async () => {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
|
|
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test("restore with lookup-only set", async () => {
|
|
|
|
|
|
|
|
const path = "node_modules";
|
|
|
|
|
|
|
|
const key = "node-test";
|
|
|
|
|
|
|
|
testUtils.setInputs({
|
|
|
|
|
|
|
|
path: path,
|
|
|
|
|
|
|
|
key,
|
|
|
|
|
|
|
|
lookupOnly: true
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const infoMock = jest.spyOn(core, "info");
|
|
|
|
|
|
|
|
const failedMock = jest.spyOn(core, "setFailed");
|
|
|
|
|
|
|
|
const stateMock = jest.spyOn(core, "saveState");
|
|
|
|
|
|
|
|
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
|
|
|
|
|
|
|
|
const restoreCacheMock = jest
|
|
|
|
|
|
|
|
.spyOn(cache, "restoreCache")
|
|
|
|
|
|
|
|
.mockImplementationOnce(() => {
|
|
|
|
|
|
|
|
return Promise.resolve(key);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await run(new StateProvider());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
|
|
|
|
|
|
|
expect(restoreCacheMock).toHaveBeenCalledWith(
|
|
|
|
|
|
|
|
[path],
|
|
|
|
|
|
|
|
key,
|
|
|
|
|
|
|
|
[],
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lookupOnly: true
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
|
|
|
|
|
|
|
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
|
|
|
|
|
|
|
|
expect(stateMock).toHaveBeenCalledTimes(2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
|
|
|
|
|
|
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(infoMock).toHaveBeenCalledWith(
|
|
|
|
|
|
|
|
`Cache found and can be restored from key: ${key}`
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
|
|
|
|
|
|
|
});
|
|
|
|