mirror of
https://github.com/actions/setup-go.git
synced 2026-01-27 06:02:09 +00:00
Update default Go module caching to use go.mod (#705)
Some checks failed
Basic validation / Basic validation (push) Failing after 0s
Validate 'setup-go' / stable (macos-latest) (push) Waiting to run
Validate 'setup-go' / stable (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / stable (windows-latest) (push) Waiting to run
Validate 'setup-go' / oldstable (macos-latest) (push) Waiting to run
Validate 'setup-go' / oldstable (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / oldstable (windows-latest) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x32, windows-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x32, windows-latest, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest, oldstable) (push) Waiting to run
Check dist/ / Check dist/ (push) Failing after 0s
Validate 'setup-go' / aliases-arch (x64, macos-latest, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest-large, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest-large, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, windows-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, windows-latest, stable) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.21.13, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.21.13, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.21.13, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.22.8, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.22.8, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.22.8, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.23.2, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.23.2, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20, macos-latest-large) (push) Waiting to run
CodeQL analysis / CodeQL analysis (push) Failing after 0s
Validate 'setup-go' / check-latest (1.20, windows-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, windows-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.22, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.22, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / check-latest (1.22, windows-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.23, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.23, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / check-latest (1.23, windows-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / go-version-file (windows-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-gowork (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-gowork (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-gowork (windows-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-tool-versions (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-tool-versions (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-tool-versions (windows-latest) (push) Waiting to run
Licensed / Licensed (push) Failing after 0s
Validate 'setup-go' / go-version-file-with-go-version (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-go-version (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-go-version (windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.20.14, macos-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.20.14, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.21.10, macos-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.21.10, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.21.10, windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.22.8, macos-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.22.8, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.22.8, windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.23.2, macos-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.23.2, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.23.2, windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-dist (1.11.12, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-dist (1.11.12, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (arm64, 1.20.14, macos-latest) (push) Waiting to run
Validate 'setup-go' / architecture (arm64, 1.21, macos-latest) (push) Waiting to run
Validate 'setup-go' / architecture (arm64, 1.22, macos-latest) (push) Waiting to run
Validate 'setup-go' / architecture (arm64, 1.23, macos-latest) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.20.14, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.21, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.21, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.22, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.22, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.23, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.23, windows-latest) (push) Waiting to run
Validate Windows installation / Validate if symlink is created (false, 1.20.1) (push) Waiting to run
Validate Windows installation / Validate if symlink is created (true, 1.20.1) (push) Waiting to run
Validate Windows installation / Find default go version (push) Waiting to run
Validate Windows installation / Validate if symlink is not created for default go (false) (push) Blocked by required conditions
Validate Windows installation / Validate if symlink is not created for default go (true) (push) Blocked by required conditions
Validate Windows installation / Validate if hostedtoolcache works as expected (false, 1.20.1) (push) Waiting to run
Validate 'setup-go' / stable (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / oldstable (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, oldstable) (push) Failing after 4s
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, stable) (push) Failing after 4s
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, oldstable) (push) Failing after 4s
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, stable) (push) Failing after 4s
Validate 'setup-go' / Setup local-cache version (1.21.13, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / Setup local-cache version (1.22.8, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / Setup local-cache version (1.23.2, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / check-latest (1.20, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / check-latest (1.21, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / check-latest (1.22, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / check-latest (1.23, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / go-version-file (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / go-version-file-with-gowork (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / go-version-file-with-tool-versions (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / go-version-file-with-go-version (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-manifest (1.20.14, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-manifest (1.21.10, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-manifest (1.22.8, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-manifest (1.23.2, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-dist (1.11.12, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / architecture (x64, 1.20.14, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / architecture (x64, 1.21, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / architecture (x64, 1.22, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / architecture (x64, 1.23, ubuntu-latest) (push) Failing after 4s
Some checks failed
Basic validation / Basic validation (push) Failing after 0s
Validate 'setup-go' / stable (macos-latest) (push) Waiting to run
Validate 'setup-go' / stable (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / stable (windows-latest) (push) Waiting to run
Validate 'setup-go' / oldstable (macos-latest) (push) Waiting to run
Validate 'setup-go' / oldstable (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / oldstable (windows-latest) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x32, windows-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x32, windows-latest, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest, oldstable) (push) Waiting to run
Check dist/ / Check dist/ (push) Failing after 0s
Validate 'setup-go' / aliases-arch (x64, macos-latest, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest-large, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest-large, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, windows-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, windows-latest, stable) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.21.13, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.21.13, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.21.13, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.22.8, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.22.8, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.22.8, windows-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.23.2, macos-latest) (push) Waiting to run
Validate 'setup-go' / Setup local-cache version (1.23.2, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20, macos-latest-large) (push) Waiting to run
CodeQL analysis / CodeQL analysis (push) Failing after 0s
Validate 'setup-go' / check-latest (1.20, windows-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, windows-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.22, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.22, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / check-latest (1.22, windows-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.23, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.23, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / check-latest (1.23, windows-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / go-version-file (windows-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-gowork (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-gowork (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-gowork (windows-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-tool-versions (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-tool-versions (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-tool-versions (windows-latest) (push) Waiting to run
Licensed / Licensed (push) Failing after 0s
Validate 'setup-go' / go-version-file-with-go-version (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-go-version (macos-latest-large) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-go-version (windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.20.14, macos-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.20.14, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.21.10, macos-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.21.10, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.21.10, windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.22.8, macos-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.22.8, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.22.8, windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.23.2, macos-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.23.2, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.23.2, windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-dist (1.11.12, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-dist (1.11.12, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (arm64, 1.20.14, macos-latest) (push) Waiting to run
Validate 'setup-go' / architecture (arm64, 1.21, macos-latest) (push) Waiting to run
Validate 'setup-go' / architecture (arm64, 1.22, macos-latest) (push) Waiting to run
Validate 'setup-go' / architecture (arm64, 1.23, macos-latest) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.20.14, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.20.14, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.21, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.21, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.22, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.22, windows-latest) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.23, macos-latest-large) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.23, windows-latest) (push) Waiting to run
Validate Windows installation / Validate if symlink is created (false, 1.20.1) (push) Waiting to run
Validate Windows installation / Validate if symlink is created (true, 1.20.1) (push) Waiting to run
Validate Windows installation / Find default go version (push) Waiting to run
Validate Windows installation / Validate if symlink is not created for default go (false) (push) Blocked by required conditions
Validate Windows installation / Validate if symlink is not created for default go (true) (push) Blocked by required conditions
Validate Windows installation / Validate if hostedtoolcache works as expected (false, 1.20.1) (push) Waiting to run
Validate 'setup-go' / stable (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / oldstable (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, oldstable) (push) Failing after 4s
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, stable) (push) Failing after 4s
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, oldstable) (push) Failing after 4s
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, stable) (push) Failing after 4s
Validate 'setup-go' / Setup local-cache version (1.21.13, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / Setup local-cache version (1.22.8, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / Setup local-cache version (1.23.2, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / check-latest (1.20, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / check-latest (1.21, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / check-latest (1.22, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / check-latest (1.23, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / go-version-file (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / go-version-file-with-gowork (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / go-version-file-with-tool-versions (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / go-version-file-with-go-version (ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-manifest (1.20.14, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-manifest (1.21.10, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-manifest (1.22.8, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-manifest (1.23.2, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / setup-versions-from-dist (1.11.12, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / architecture (x64, 1.20.14, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / architecture (x64, 1.21, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / architecture (x64, 1.22, ubuntu-latest) (push) Failing after 4s
Validate 'setup-go' / architecture (x64, 1.23, ubuntu-latest) (push) Failing after 4s
* Update module cache to use go.mod as key * Fix typo * Revise breaking changes in README for V6 Updated breaking changes section with enhanced formatting and clarified toolchain management details.
This commit is contained in:
@@ -1,94 +1,83 @@
|
||||
import * as cache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import * as glob from '@actions/glob';
|
||||
import fs from 'fs';
|
||||
|
||||
import * as cacheRestore from '../src/cache-restore';
|
||||
import * as cacheUtils from '../src/cache-utils';
|
||||
import {PackageManagerInfo} from '../src/package-managers';
|
||||
|
||||
describe('restoreCache', () => {
|
||||
//Arrange
|
||||
const hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
||||
const getCacheDirectoryPathSpy = jest.spyOn(
|
||||
cacheUtils,
|
||||
'getCacheDirectoryPath'
|
||||
);
|
||||
const restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
|
||||
const infoSpy = jest.spyOn(core, 'info');
|
||||
const setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||
let hashFilesSpy: jest.SpyInstance;
|
||||
let getCacheDirectoryPathSpy: jest.SpyInstance;
|
||||
let restoreCacheSpy: jest.SpyInstance;
|
||||
let infoSpy: jest.SpyInstance;
|
||||
let setOutputSpy: jest.SpyInstance;
|
||||
|
||||
const versionSpec = '1.13.1';
|
||||
const packageManager = 'default';
|
||||
const cacheDependencyPath = 'path';
|
||||
|
||||
let originalWorkspace: string | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
originalWorkspace = process.env.GITHUB_WORKSPACE;
|
||||
process.env.GITHUB_WORKSPACE = '/test/workspace';
|
||||
//Arrange
|
||||
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
||||
getCacheDirectoryPathSpy = jest.spyOn(cacheUtils, 'getCacheDirectoryPath');
|
||||
restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
|
||||
infoSpy = jest.spyOn(core, 'info');
|
||||
setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||
|
||||
getCacheDirectoryPathSpy.mockImplementation(
|
||||
(PackageManager: PackageManagerInfo) => {
|
||||
return new Promise<string[]>(resolve => {
|
||||
resolve(['cache_directory_path', 'cache_directory_path']);
|
||||
});
|
||||
return Promise.resolve([
|
||||
'cache_directory_path',
|
||||
'cache_directory_path'
|
||||
]);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw if dependency file path is not valid', async () => {
|
||||
//Arrange
|
||||
hashFilesSpy.mockImplementation((somePath: string) => {
|
||||
return new Promise<string>(resolve => {
|
||||
resolve('');
|
||||
});
|
||||
});
|
||||
afterEach(() => {
|
||||
process.env.GITHUB_WORKSPACE = originalWorkspace;
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
//Act + Assert
|
||||
await expect(async () => {
|
||||
await cacheRestore.restoreCache(
|
||||
it('should throw if dependency file path is not valid', async () => {
|
||||
// Arrange
|
||||
hashFilesSpy.mockImplementation(() => Promise.resolve(''));
|
||||
// Act + Assert
|
||||
await expect(
|
||||
cacheRestore.restoreCache(
|
||||
versionSpec,
|
||||
packageManager,
|
||||
cacheDependencyPath
|
||||
);
|
||||
}).rejects.toThrow(
|
||||
)
|
||||
).rejects.toThrow(
|
||||
'Some specified paths were not resolved, unable to cache dependencies.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should inform if cache hit is not occured', async () => {
|
||||
//Arrange
|
||||
hashFilesSpy.mockImplementation((somePath: string) => {
|
||||
return new Promise<string>(resolve => {
|
||||
resolve('file_hash');
|
||||
});
|
||||
});
|
||||
|
||||
restoreCacheSpy.mockImplementation(() => {
|
||||
return new Promise<string>(resolve => {
|
||||
resolve('');
|
||||
});
|
||||
});
|
||||
|
||||
//Act + Assert
|
||||
it('should inform if cache hit is not occurred', async () => {
|
||||
// Arrange
|
||||
hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
|
||||
restoreCacheSpy.mockImplementation(() => Promise.resolve(''));
|
||||
// Act + Assert
|
||||
await cacheRestore.restoreCache(
|
||||
versionSpec,
|
||||
packageManager,
|
||||
cacheDependencyPath
|
||||
);
|
||||
expect(infoSpy).toHaveBeenCalledWith(`Cache is not found`);
|
||||
expect(infoSpy).toHaveBeenCalledWith('Cache is not found');
|
||||
});
|
||||
|
||||
it('should set output if cache hit is occured', async () => {
|
||||
//Arrange
|
||||
hashFilesSpy.mockImplementation((somePath: string) => {
|
||||
return new Promise<string>(resolve => {
|
||||
resolve('file_hash');
|
||||
});
|
||||
});
|
||||
|
||||
restoreCacheSpy.mockImplementation(() => {
|
||||
return new Promise<string>(resolve => {
|
||||
resolve('cache_key');
|
||||
});
|
||||
});
|
||||
|
||||
//Act + Assert
|
||||
it('should set output if cache hit is occurred', async () => {
|
||||
// Arrange
|
||||
hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
|
||||
restoreCacheSpy.mockImplementation(() => Promise.resolve('cache_key'));
|
||||
// Act + Assert
|
||||
await cacheRestore.restoreCache(
|
||||
versionSpec,
|
||||
packageManager,
|
||||
@@ -96,4 +85,18 @@ describe('restoreCache', () => {
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
||||
});
|
||||
|
||||
it('should throw if dependency file is not found in workspace', async () => {
|
||||
jest.spyOn(fs, 'readdirSync').mockReturnValue(['main.go'] as any);
|
||||
|
||||
await expect(
|
||||
cacheRestore.restoreCache(
|
||||
versionSpec,
|
||||
packageManager
|
||||
// No cacheDependencyPath
|
||||
)
|
||||
).rejects.toThrow(
|
||||
'Dependencies file is not found in /test/workspace. Supported file pattern: go.mod'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('getPackageManagerInfo', () => {
|
||||
//Arrange
|
||||
const packageManagerName = 'default';
|
||||
const expectedResult = {
|
||||
dependencyFilePattern: 'go.sum',
|
||||
dependencyFilePattern: 'go.mod',
|
||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ describe('getCacheDirectoryPath', () => {
|
||||
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||
|
||||
const validPackageManager: PackageManagerInfo = {
|
||||
dependencyFilePattern: 'go.sum',
|
||||
dependencyFilePattern: 'go.mod',
|
||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user