mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-05-07 18:29:54 +02:00
Merge master into ethanis/cache-multiple-paths
This commit is contained in:
commit
f68f5d03cc
15 changed files with 3437 additions and 602 deletions
|
@ -341,3 +341,15 @@ test("isValidEvent returns true for pull request event", () => {
|
|||
|
||||
expect(isValidEvent).toBe(true);
|
||||
});
|
||||
|
||||
test("unlinkFile unlinks file", async () => {
|
||||
const testDirectory = fs.mkdtempSync("unlinkFileTest");
|
||||
const testFile = path.join(testDirectory, "test.txt");
|
||||
fs.writeFileSync(testFile, "hello world");
|
||||
|
||||
await actionUtils.unlinkFile(testFile);
|
||||
|
||||
expect(fs.existsSync(testFile)).toBe(false);
|
||||
|
||||
fs.rmdirSync(testDirectory);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import * as core from "@actions/core";
|
||||
import * as path from "path";
|
||||
|
||||
import * as cacheHttpClient from "../src/cacheHttpClient";
|
||||
import { Events, Inputs } from "../src/constants";
|
||||
import { ArtifactCacheEntry } from "../src/contracts";
|
||||
|
@ -236,6 +237,7 @@ test("restore with cache found", async () => {
|
|||
.mockReturnValue(fileSize);
|
||||
|
||||
const extractTarMock = jest.spyOn(tar, "extractTar");
|
||||
const unlinkFileMock = jest.spyOn(actionUtils, "unlinkFile");
|
||||
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
|
||||
|
||||
await run();
|
||||
|
@ -253,6 +255,9 @@ test("restore with cache found", async () => {
|
|||
expect(extractTarMock).toHaveBeenCalledTimes(1);
|
||||
expect(extractTarMock).toHaveBeenCalledWith(archivePath);
|
||||
|
||||
expect(unlinkFileMock).toHaveBeenCalledTimes(1);
|
||||
expect(unlinkFileMock).toHaveBeenCalledWith(archivePath);
|
||||
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(true);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import * as core from "@actions/core";
|
||||
import * as path from "path";
|
||||
|
||||
import * as cacheHttpClient from "../src/cacheHttpClient";
|
||||
import { Events, Inputs, CacheFilename } from "../src/constants";
|
||||
import { ArtifactCacheEntry } from "../src/contracts";
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as exec from "@actions/exec";
|
|||
import * as io from "@actions/io";
|
||||
import { promises as fs } from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import * as tar from "../src/tar";
|
||||
import { CacheFilename } from "../src/constants";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue