1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-05-07 18:29:54 +02:00

Include keys in getCacheEntry request

This commit is contained in:
Ethan Dennis 2020-03-16 12:49:13 -07:00
parent bd756c16ae
commit 072d513f28
No known key found for this signature in database
GPG key ID: 32E74B75DB4065DD
6 changed files with 19 additions and 37 deletions

View file

@ -1,34 +1,18 @@
import * as testUtils from "../src/utils/testUtils";
import { getCacheVersion } from "../src/cacheHttpClient";
import { Inputs } from "../src/constants";
afterEach(() => {
testUtils.clearInputs();
});
test("getCacheVersion with no restore keys returns version", async () => {
testUtils.setInputs({
path: "node-test",
key: "node_modules"
});
test("getCacheVersion with path input returns version", async () => {
testUtils.setInput(Inputs.Path, "node_modules");
const result = getCacheVersion();
expect(result).toEqual(
"ee9d5dc2e8e2df8e32f62c367796abefc134790584015d8e1207523c9085e87e"
);
});
test("getCacheVersion with restore keys returns version", async () => {
testUtils.setInputs({
path: "node-test",
key: "node_modules",
restoreKeys: ["node-", "node"]
});
const result = getCacheVersion();
expect(result).toEqual(
"b8596b1e42c34a25be7b43c7b91892ed3ba81cba1e075365f408b35dbfabb61b"
"b3e0c6cb5ecf32614eeb2997d905b9c297046d7cbf69062698f25b14b4cb0985"
);
});

View file

@ -241,7 +241,7 @@ test("restore with cache found", async () => {
await run();
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(getCacheMock).toHaveBeenCalledWith();
expect(getCacheMock).toHaveBeenCalledWith([key]);
expect(setCacheStateMock).toHaveBeenCalledWith(cacheEntry);
expect(createTempDirectoryMock).toHaveBeenCalledTimes(1);
expect(downloadCacheMock).toHaveBeenCalledWith(
@ -307,7 +307,7 @@ test("restore with a pull request event and cache found", async () => {
await run();
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(getCacheMock).toHaveBeenCalledWith();
expect(getCacheMock).toHaveBeenCalledWith([key]);
expect(setCacheStateMock).toHaveBeenCalledWith(cacheEntry);
expect(createTempDirectoryMock).toHaveBeenCalledTimes(1);
expect(downloadCacheMock).toHaveBeenCalledWith(
@ -374,7 +374,7 @@ test("restore with cache found for restore key", async () => {
await run();
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(getCacheMock).toHaveBeenCalledWith();
expect(getCacheMock).toHaveBeenCalledWith([key, restoreKey]);
expect(setCacheStateMock).toHaveBeenCalledWith(cacheEntry);
expect(createTempDirectoryMock).toHaveBeenCalledTimes(1);
expect(downloadCacheMock).toHaveBeenCalledWith(