1
0
Fork 0
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:
Ethan Dennis 2020-03-18 17:35:59 -07:00
commit f68f5d03cc
No known key found for this signature in database
GPG key ID: 32E74B75DB4065DD
15 changed files with 3437 additions and 602 deletions

View file

@ -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);
});

View file

@ -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);

View file

@ -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";

View file

@ -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";