1
0
mirror of https://gitea.com/actions/cache.git synced 2026-01-21 06:44:29 +07:00

Add save-always inpute/output test

This commit is contained in:
Danny Gleckler
2024-02-08 20:52:30 -05:00
parent 727a4d2137
commit 2d00cd51fd
2 changed files with 41 additions and 0 deletions

View File

@@ -473,3 +473,40 @@ test("restore with lookup-only set", async () => {
);
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("restore with save-always set", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
const path = "node_modules";
const key = "node-test";
testUtils.setInputs({
path: path,
key,
saveAlways: true
});
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(undefined);
});
await restoreImpl(new StateProvider());
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(restoreCacheMock).toHaveBeenCalledWith(
[path],
key,
[],
{
lookupOnly: false
},
false
);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
"save-always-d18d746b9",
"true"
);
});