Validate 'setup-go' / stable (macos-13) (push) Waiting to run
Validate 'setup-go' / stable (macos-latest) (push) Waiting to run
Validate 'setup-go' / stable (ubuntu-latest) (push) Waiting to run
Validate 'setup-go' / stable (windows-latest) (push) Waiting to run
Validate 'setup-go' / oldstable (macos-13) (push) Waiting to run
Validate 'setup-go' / oldstable (macos-latest) (push) Waiting to run
Validate 'setup-go' / oldstable (ubuntu-latest) (push) Waiting to run
Validate 'setup-go' / oldstable (windows-latest) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, stable) (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-13, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-13, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, macos-latest, stable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, oldstable) (push) Waiting to run
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, 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-13) (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, ubuntu-latest) (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-13) (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, ubuntu-latest) (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-13) (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, ubuntu-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20, macos-13) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20, ubuntu-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.20, windows-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, macos-13) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.21, ubuntu-latest) (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-13) (push) Waiting to run
Validate 'setup-go' / check-latest (1.22, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.22, ubuntu-latest) (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-13) (push) Waiting to run
Validate 'setup-go' / check-latest (1.23, macos-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.23, ubuntu-latest) (push) Waiting to run
Validate 'setup-go' / check-latest (1.23, windows-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file (macos-13) (push) Waiting to run
Validate 'setup-go' / go-version-file (macos-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file (ubuntu-latest) (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-13) (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 (ubuntu-latest) (push) Waiting to run
Validate 'setup-go' / go-version-file-with-gowork (windows-latest) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-manifest (1.20.14, ubuntu-latest) (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-13) (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, ubuntu-latest) (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.20.14, macos-13) (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.22.8, macos-13) (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, ubuntu-latest) (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-13) (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, ubuntu-latest) (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-13) (push) Waiting to run
Validate 'setup-go' / setup-versions-from-dist (1.11.12, ubuntu-latest) (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-13) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.20.14, ubuntu-latest) (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-13) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.21, ubuntu-latest) (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-13) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.22, ubuntu-latest) (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-13) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.23, ubuntu-latest) (push) Waiting to run
Validate 'setup-go' / architecture (x64, 1.23, windows-latest) (push) Waiting to run
Validate Windows installation / Validate if symlink is not created for default go (false) (push) Canceled after 0s
Validate Windows installation / Validate if symlink is not created for default go (true) (push) Canceled after 0s
Validate Windows installation / Validate if symlink is created (false, 1.20.1) (push) Failing after 0s
Validate Windows installation / Validate if symlink is created (true, 1.20.1) (push) Failing after 0s
Validate Windows installation / Find default go version (push) Failing after 0s
Validate Windows installation / Validate if hostedtoolcache works as expected (false, 1.20.1) (push) Failing after 0s
100 lines
2.6 KiB
TypeScript
100 lines
2.6 KiB
TypeScript
import * as cache from '@actions/cache';
|
|
import * as core from '@actions/core';
|
|
import * as glob from '@actions/glob';
|
|
|
|
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');
|
|
|
|
const versionSpec = '1.13.1';
|
|
const packageManager = 'default';
|
|
const cacheDependencyPath = 'path';
|
|
|
|
beforeEach(() => {
|
|
getCacheDirectoryPathSpy.mockImplementation(
|
|
(PackageManager: PackageManagerInfo) => {
|
|
return new Promise<string[]>(resolve => {
|
|
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('');
|
|
});
|
|
});
|
|
|
|
//Act + Assert
|
|
await expect(async () => {
|
|
await cacheRestore.restoreCache(
|
|
versionSpec,
|
|
packageManager,
|
|
cacheDependencyPath
|
|
);
|
|
}).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
|
|
await cacheRestore.restoreCache(
|
|
versionSpec,
|
|
packageManager,
|
|
cacheDependencyPath
|
|
);
|
|
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
|
|
await cacheRestore.restoreCache(
|
|
versionSpec,
|
|
packageManager,
|
|
cacheDependencyPath
|
|
);
|
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
|
});
|
|
});
|