mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-22 16:53:57 +08:00
Add outputs.cache-key
This commit is contained in:
parent
dbb732b211
commit
dde36b38ea
8 changed files with 58 additions and 12 deletions
|
@ -102,7 +102,8 @@ test("setOutputAndState with exact match to set cache-hit output and state", ()
|
|||
actionUtils.setOutputAndState(key, cacheKey);
|
||||
|
||||
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "true");
|
||||
expect(setOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheKey, key);
|
||||
expect(setOutputMock).toHaveBeenCalledTimes(2);
|
||||
|
||||
expect(saveStateMock).toHaveBeenCalledWith(State.CacheMatchedKey, cacheKey);
|
||||
expect(saveStateMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -118,7 +119,8 @@ test("setOutputAndState with no exact match to set cache-hit output and state",
|
|||
actionUtils.setOutputAndState(key, cacheKey);
|
||||
|
||||
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "false");
|
||||
expect(setOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheKey, key);
|
||||
expect(setOutputMock).toHaveBeenCalledTimes(2);
|
||||
|
||||
expect(saveStateMock).toHaveBeenCalledWith(State.CacheMatchedKey, cacheKey);
|
||||
expect(saveStateMock).toHaveBeenCalledTimes(1);
|
||||
|
|
|
@ -158,6 +158,7 @@ test("restore with no cache found", async () => {
|
|||
const infoMock = jest.spyOn(core, "info");
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const stateMock = jest.spyOn(core, "saveState");
|
||||
const setOutputMock = jest.spyOn(core, "setOutput");
|
||||
const restoreCacheMock = jest
|
||||
.spyOn(cache, "restoreCache")
|
||||
.mockImplementationOnce(() => {
|
||||
|
@ -172,6 +173,8 @@ test("restore with no cache found", async () => {
|
|||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
|
||||
expect(setOutputMock).toHaveBeenCalledTimes(0);
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
`Cache not found for input keys: ${key}`
|
||||
);
|
||||
|
@ -270,7 +273,7 @@ test("restore with cache found for key", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(true);
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
|
||||
expect(infoMock).toHaveBeenCalledWith(`Cache restored for key: ${key}`);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue