10
0
Fork 0
mirror of https://github.com/actions/cache.git synced 2026-04-06 23:06:59 +00:00

feat: Introduced restore-only flag

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

View file

@ -406,3 +406,34 @@ test("save with valid inputs uploads a cache", async () => {
expect(failedMock).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."
);
});