12
0
Fork 0
mirror of https://github.com/actions/cache.git synced 2026-07-02 13:19:31 +00:00

feat: Introduced restore-only flag

This commit is contained in:
Guillermo Mazzola 2026-04-01 22:12:08 +02:00
parent 55cc834586
commit ed7b7dd218
No known key found for this signature in database
GPG key ID: 6A17887FBC885E08
10 changed files with 63 additions and 5 deletions

View file

@ -282,3 +282,34 @@ test("save with valid inputs uploads a cache", async () => {
expect(core.setFailed).toHaveBeenCalledTimes(0);
});
test("save with restore-only should no-op", async () => {
const primaryKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
const savedCacheKey = "Linux-node-";
jest.spyOn(core, "getState")
// Cache Entry State
.mockImplementationOnce(() => {
return savedCacheKey;
})
// Cache Key State
.mockImplementationOnce(() => {
return primaryKey;
});
const inputPath = "node_modules";
testUtils.setInput(Inputs.Path, inputPath);
testUtils.setInput(Inputs.RestoreOnly, "true");
const infoMock = jest.spyOn(core, "info");
const saveCacheMock = jest.spyOn(cache, "saveCache");
await saveImpl(new StateProvider());
expect(saveCacheMock).toHaveBeenCalledTimes(0);
expect(infoMock).toHaveBeenCalledWith(
"Skipping saving cache as 'restore-only' option is set."
);
});