mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-05-03 08:49:54 +02:00
unit test coverage for caching multiple dirs
This commit is contained in:
parent
e0d1942524
commit
057d9de723
11 changed files with 161 additions and 80 deletions
|
@ -1,7 +1,7 @@
|
|||
import * as core from "@actions/core";
|
||||
import * as path from "path";
|
||||
import * as cacheHttpClient from "../src/cacheHttpClient";
|
||||
import { Events, Inputs } from "../src/constants";
|
||||
import { Events, Inputs, CacheFilename } from "../src/constants";
|
||||
import { ArtifactCacheEntry } from "../src/contracts";
|
||||
import run from "../src/save";
|
||||
import * as tar from "../src/tar";
|
||||
|
@ -204,10 +204,10 @@ test("save with large cache outputs warning", async () => {
|
|||
|
||||
await run();
|
||||
|
||||
const archivePath = path.join("/foo/bar", "cache.tgz");
|
||||
const archiveFolder = "/foo/bar";
|
||||
|
||||
expect(createTarMock).toHaveBeenCalledTimes(1);
|
||||
expect(createTarMock).toHaveBeenCalledWith(archivePath, cachePaths);
|
||||
expect(createTarMock).toHaveBeenCalledWith(archiveFolder, cachePaths);
|
||||
|
||||
expect(logWarningMock).toHaveBeenCalledTimes(1);
|
||||
expect(logWarningMock).toHaveBeenCalledWith(
|
||||
|
@ -314,13 +314,14 @@ test("save with server error outputs warning", async () => {
|
|||
expect(reserveCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(reserveCacheMock).toHaveBeenCalledWith(primaryKey);
|
||||
|
||||
const archivePath = path.join("/foo/bar", "cache.tgz");
|
||||
const archiveFolder = "/foo/bar";
|
||||
const archiveFile = path.join(archiveFolder, CacheFilename);
|
||||
|
||||
expect(createTarMock).toHaveBeenCalledTimes(1);
|
||||
expect(createTarMock).toHaveBeenCalledWith(archivePath, cachePaths);
|
||||
expect(createTarMock).toHaveBeenCalledWith(archiveFolder, cachePaths);
|
||||
|
||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(saveCacheMock).toHaveBeenCalledWith(cacheId, archivePath);
|
||||
expect(saveCacheMock).toHaveBeenCalledWith(cacheId, archiveFile);
|
||||
|
||||
expect(logWarningMock).toHaveBeenCalledTimes(1);
|
||||
expect(logWarningMock).toHaveBeenCalledWith("HTTP Error Occurred");
|
||||
|
@ -369,13 +370,14 @@ test("save with valid inputs uploads a cache", async () => {
|
|||
expect(reserveCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(reserveCacheMock).toHaveBeenCalledWith(primaryKey);
|
||||
|
||||
const archivePath = path.join("/foo/bar", "cache.tgz");
|
||||
const archiveFolder = "/foo/bar";
|
||||
const archiveFile = path.join(archiveFolder, CacheFilename);
|
||||
|
||||
expect(createTarMock).toHaveBeenCalledTimes(1);
|
||||
expect(createTarMock).toHaveBeenCalledWith(archivePath, cachePaths);
|
||||
expect(createTarMock).toHaveBeenCalledWith(archiveFolder, cachePaths);
|
||||
|
||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(saveCacheMock).toHaveBeenCalledWith(cacheId, archivePath);
|
||||
expect(saveCacheMock).toHaveBeenCalledWith(cacheId, archiveFile);
|
||||
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue