3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2026-01-09 05:08:57 +00:00

pull request feedback

This commit is contained in:
StephenHodgson 2025-12-13 16:25:35 -05:00
parent 6018dbe2dc
commit 114dd526d5
4 changed files with 157 additions and 8 deletions

View file

@ -473,7 +473,10 @@ test("save applies compression level when provided", async () => {
test("save skips setting compression when value is out of range", async () => {
const failedMock = jest.spyOn(core, "setFailed");
const setCompressionLevelMock = jest.spyOn(actionUtils, "setCompressionLevel");
const setCompressionLevelMock = jest.spyOn(
actionUtils,
"setCompressionLevel"
);
const primaryKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
const savedCacheKey = "Linux-node-";
@ -518,3 +521,54 @@ test("save skips setting compression when value is out of range", async () => {
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("save skips setting compression when value is negative", async () => {
const failedMock = jest.spyOn(core, "setFailed");
const setCompressionLevelMock = jest.spyOn(
actionUtils,
"setCompressionLevel"
);
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.UploadChunkSize, "4000000");
testUtils.setInput(Inputs.CompressionLevel, "-1");
const cacheId = 4;
const saveCacheMock = jest
.spyOn(cache, "saveCache")
.mockImplementationOnce(() => {
return Promise.resolve(cacheId);
});
await saveImpl(new StateProvider());
expect(process.env["ZSTD_CLEVEL"]).toBeUndefined();
expect(process.env["GZIP"]).toBeUndefined();
expect(setCompressionLevelMock).not.toHaveBeenCalled();
expect(saveCacheMock).toHaveBeenCalledTimes(1);
expect(saveCacheMock).toHaveBeenCalledWith(
[inputPath],
primaryKey,
{
uploadChunkSize: 4000000
},
false
);
expect(failedMock).toHaveBeenCalledTimes(0);
});