diff --git a/__tests__/restore.test.ts b/__tests__/restore.test.ts index 446237c46..e42ea9da2 100644 --- a/__tests__/restore.test.ts +++ b/__tests__/restore.test.ts @@ -1,6 +1,6 @@ -import * as cache from "@actions/cache"; import * as core from "@actions/core"; +import * as cache from "../src/cache"; import { Events, Inputs, RefKey } from "../src/constants"; import run from "../src/restore"; import * as actionUtils from "../src/utils/actionUtils"; @@ -94,42 +94,6 @@ test("restore with no key", async () => { ); }); -test("restore with too many keys should fail", async () => { - const path = "node_modules"; - const key = "node-test"; - const restoreKeys = [...Array(20).keys()].map(x => x.toString()); - testUtils.setInputs({ - path: path, - key, - restoreKeys - }); - const failedMock = jest.spyOn(core, "setFailed"); - const restoreCacheMock = jest.spyOn(cache, "restoreCache"); - await run(); - expect(restoreCacheMock).toHaveBeenCalledTimes(1); - expect(restoreCacheMock).toHaveBeenCalledWith([path], key, restoreKeys); - expect(failedMock).toHaveBeenCalledWith( - `Key Validation Error: Keys are limited to a maximum of 10.` - ); -}); - -test("restore with large key should fail", async () => { - const path = "node_modules"; - const key = "foo".repeat(512); // Over the 512 character limit - testUtils.setInputs({ - path: path, - key - }); - const failedMock = jest.spyOn(core, "setFailed"); - const restoreCacheMock = jest.spyOn(cache, "restoreCache"); - await run(); - expect(restoreCacheMock).toHaveBeenCalledTimes(1); - expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); - expect(failedMock).toHaveBeenCalledWith( - `Key Validation Error: ${key} cannot be larger than 512 characters.` - ); -}); - test("restore with invalid key should fail", async () => { const path = "node_modules"; const key = "comma,comma"; diff --git a/__tests__/save.test.ts b/__tests__/save.test.ts index b806d5096..6397332a9 100644 --- a/__tests__/save.test.ts +++ b/__tests__/save.test.ts @@ -1,13 +1,13 @@ -import * as cache from "@actions/cache"; import * as core from "@actions/core"; +import * as cache from "../src/cache"; import { Events, Inputs, RefKey } from "../src/constants"; import run from "../src/save"; import * as actionUtils from "../src/utils/actionUtils"; import * as testUtils from "../src/utils/testUtils"; jest.mock("@actions/core"); -jest.mock("@actions/cache"); +jest.mock("../src/cache"); jest.mock("../src/utils/actionUtils"); beforeAll(() => { @@ -170,50 +170,6 @@ test("save with missing input outputs warning", async () => { expect(failedMock).toHaveBeenCalledTimes(0); }); -test("save with large cache outputs warning", async () => { - const logWarningMock = jest.spyOn(actionUtils, "logWarning"); - const failedMock = jest.spyOn(core, "setFailed"); - - 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); - - const saveCacheMock = jest - .spyOn(cache, "saveCache") - .mockImplementationOnce(() => { - throw new Error( - "Cache size of ~6144 MB (6442450944 B) is over the 5GB limit, not saving cache." - ); - }); - - await run(); - - expect(saveCacheMock).toHaveBeenCalledTimes(1); - expect(saveCacheMock).toHaveBeenCalledWith( - [inputPath], - primaryKey, - expect.anything() - ); - - expect(logWarningMock).toHaveBeenCalledTimes(1); - expect(logWarningMock).toHaveBeenCalledWith( - "Cache size of ~6144 MB (6442450944 B) is over the 5GB limit, not saving cache." - ); - expect(failedMock).toHaveBeenCalledTimes(0); -}); - test("save with reserve cache failure outputs warning", async () => { const infoMock = jest.spyOn(core, "info"); const logWarningMock = jest.spyOn(actionUtils, "logWarning");