feat: force-update

This commit is contained in:
Dulmandakh 2022-03-07 23:43:23 +08:00
parent c7c46bcb6d
commit 17151cf67e
4 changed files with 37 additions and 3 deletions

View file

@ -142,6 +142,38 @@ test("save with exact match returns early", async () => {
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("save with force-update", async () => {
const failedMock = jest.spyOn(core, "setFailed");
const primaryKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
const savedCacheKey = primaryKey;
jest.spyOn(core, "getState")
// Cache Entry State
.mockImplementationOnce(() => {
return savedCacheKey;
})
// Cache Key State
.mockImplementationOnce(() => {
return primaryKey;
});
testUtils.setInput(Inputs.ForceUpdate, "true");
testUtils.setInput(Inputs.Path, "node_modules");
const cacheId = 4;
const saveCacheMock = jest
.spyOn(cache, "saveCache")
.mockImplementationOnce(() => {
return Promise.resolve(cacheId);
});
await run();
expect(saveCacheMock).toHaveBeenCalledTimes(1);
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("save with missing input outputs warning", async () => {
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
const failedMock = jest.spyOn(core, "setFailed");