Some checks failed
Check dist/ / Check dist/ (push) Has been cancelled
CodeQL analysis / CodeQL analysis (push) Has been cancelled
Basic validation / Basic validation (push) Has been cancelled
e2e tests / test-setup-multiple-versions (macos-13) (push) Has been cancelled
e2e tests / test-setup-multiple-versions (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-multiple-versions (windows-latest) (push) Has been cancelled
e2e tests / test-setup-multiple-versions-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-multiple-versions-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-setup-full-version (macos-13) (push) Has been cancelled
e2e tests / test-setup-full-version (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-full-version (windows-latest) (push) Has been cancelled
e2e tests / test-setup-full-version-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-full-version-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-setup-without-patch-version (macos-13) (push) Has been cancelled
e2e tests / test-setup-without-patch-version (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-without-patch-version (windows-latest) (push) Has been cancelled
e2e tests / test-setup-without-patch-version-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-without-patch-version-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-setup-prerelease-version (macos-13) (push) Has been cancelled
e2e tests / test-setup-prerelease-version (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-prerelease-version (windows-latest) (push) Has been cancelled
e2e tests / test-setup-prerelease-version-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-prerelease-version-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-setup-latest-patch-version (macos-13) (push) Has been cancelled
e2e tests / test-setup-latest-patch-version (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-latest-patch-version (windows-latest) (push) Has been cancelled
e2e tests / test-setup-latest-patch-version-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-latest-patch-version-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-ABCxx-syntax (macos-13) (push) Has been cancelled
e2e tests / test-ABCxx-syntax (macos-latest) (push) Has been cancelled
e2e tests / test-ABCxx-syntax (ubuntu-latest) (push) Has been cancelled
e2e tests / test-ABCxx-syntax (windows-latest) (push) Has been cancelled
e2e tests / test-setup-with-wildcard (macos-13) (push) Has been cancelled
e2e tests / test-setup-with-wildcard (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-with-wildcard (windows-latest) (push) Has been cancelled
e2e tests / test-setup-with-wildcard-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-with-wildcard-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-setup-global-json-specified-and-version (macos-13) (push) Has been cancelled
e2e tests / test-setup-global-json-specified-and-version (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-global-json-specified-and-version (windows-latest) (push) Has been cancelled
e2e tests / test-setup-global-json-specified-and-version-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-global-json-specified-and-version-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-setup-global-json-only (macos-13) (push) Has been cancelled
e2e tests / test-setup-global-json-only (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-global-json-only (windows-latest) (push) Has been cancelled
e2e tests / test-setup-global-json-only-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-global-json-only-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-global-json-with-comments (macos-13) (push) Has been cancelled
e2e tests / test-global-json-with-comments (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-global-json-with-comments (windows-latest) (push) Has been cancelled
e2e tests / test-global-json-with-comments-extended (macos-latest) (push) Has been cancelled
e2e tests / test-global-json-with-comments-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-setup-with-dotnet-quality (macos-13) (push) Has been cancelled
e2e tests / test-setup-with-dotnet-quality (macos-latest) (push) Has been cancelled
e2e tests / test-setup-with-dotnet-quality (ubuntu-latest) (push) Has been cancelled
e2e tests / test-setup-with-dotnet-quality (windows-latest) (push) Has been cancelled
e2e tests / test-setup-with-cache (macos-13) (push) Has been cancelled
e2e tests / test-setup-with-cache (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-with-cache (windows-latest) (push) Has been cancelled
e2e tests / test-setup-with-cache-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-with-cache-extended (ubuntu-latest) (push) Has been cancelled
e2e tests / test-setup-with-cache-dependency-path (macos-13) (push) Has been cancelled
e2e tests / test-bypass-proxy-extended (push) Has been cancelled
e2e tests / test-setup-with-cache-dependency-path (ubuntu-22.04) (push) Has been cancelled
e2e tests / test-setup-with-cache-dependency-path (windows-latest) (push) Has been cancelled
e2e tests / test-setup-with-cache-dependency-path-extended (macos-latest) (push) Has been cancelled
e2e tests / test-setup-with-cache-dependency-path-extended (ubuntu-latest) (push) Has been cancelled
Validate dotnet / setup-version (2.2, ubuntu-22.04) (push) Has been cancelled
e2e tests / test-dotnet-version-output-during-single-version-installation (macos-13) (push) Has been cancelled
e2e tests / test-dotnet-version-output-during-single-version-installation (macos-latest) (push) Has been cancelled
e2e tests / test-dotnet-version-output-during-single-version-installation (ubuntu-latest) (push) Has been cancelled
e2e tests / test-dotnet-version-output-during-single-version-installation (windows-latest) (push) Has been cancelled
e2e tests / test-dotnet-version-output-during-multiple-version-installation (macos-13) (push) Has been cancelled
e2e tests / test-dotnet-version-output-during-multiple-version-installation (macos-latest) (push) Has been cancelled
e2e tests / test-dotnet-version-output-during-multiple-version-installation (ubuntu-latest) (push) Has been cancelled
e2e tests / test-dotnet-version-output-during-multiple-version-installation (windows-latest) (push) Has been cancelled
e2e tests / test-proxy (push) Has been cancelled
e2e tests / test-bypass-proxy (push) Has been cancelled
e2e tests / test-sequential-version-installation (7.0.203, 3.1.426, macos-13) (push) Has been cancelled
e2e tests / test-sequential-version-installation (7.0.203, 3.1.426, ubuntu-22.04) (push) Has been cancelled
e2e tests / test-sequential-version-installation (7.0.203, 3.1.426, windows-latest) (push) Has been cancelled
e2e tests / test-sequential-version-installation-extended (8.0.403, 6.0.425, macos-latest) (push) Has been cancelled
e2e tests / test-sequential-version-installation-extended (8.0.403, 6.0.425, ubuntu-latest) (push) Has been cancelled
Licensed / Licensed (push) Has been cancelled
Validate dotnet / setup-version (2.1, macos-13) (push) Has been cancelled
Validate dotnet / setup-version (2.1, ubuntu-22.04) (push) Has been cancelled
Validate dotnet / setup-version (2.1, windows-latest) (push) Has been cancelled
Validate dotnet / setup-version (2.2, macos-13) (push) Has been cancelled
Validate dotnet / setup-version (2.2, windows-latest) (push) Has been cancelled
Validate dotnet / setup-version (3.0, macos-13) (push) Has been cancelled
Validate dotnet / setup-version (3.0, ubuntu-22.04) (push) Has been cancelled
Validate dotnet / setup-version (3.0, windows-latest) (push) Has been cancelled
Validate dotnet / setup-version (3.1, macos-13) (push) Has been cancelled
Validate dotnet / setup-version (3.1, ubuntu-22.04) (push) Has been cancelled
Validate dotnet / setup-version (3.1, windows-latest) (push) Has been cancelled
Validate dotnet / setup-version (5.0, macos-13) (push) Has been cancelled
Validate dotnet / setup-version (5.0, ubuntu-22.04) (push) Has been cancelled
Validate dotnet / setup-version (5.0, windows-latest) (push) Has been cancelled
Validate dotnet / setup-version (6.0, macos-13) (push) Has been cancelled
Validate dotnet / setup-version (6.0, macos-latest) (push) Has been cancelled
Validate dotnet / setup-version (6.0, ubuntu-22.04) (push) Has been cancelled
Validate dotnet / setup-version (6.0, ubuntu-latest) (push) Has been cancelled
Validate dotnet / setup-version (6.0, windows-latest) (push) Has been cancelled
Validate dotnet / setup-version (7.0, macos-13) (push) Has been cancelled
Validate dotnet / setup-version (7.0, macos-latest) (push) Has been cancelled
Validate dotnet / setup-version (7.0, ubuntu-22.04) (push) Has been cancelled
Validate dotnet / setup-version (7.0, ubuntu-latest) (push) Has been cancelled
Validate dotnet / setup-version (7.0, windows-latest) (push) Has been cancelled
Validate dotnet / setup-version (8.0, macos-13) (push) Has been cancelled
Validate dotnet / setup-version (8.0, macos-latest) (push) Has been cancelled
Validate dotnet / setup-version (8.0, ubuntu-22.04) (push) Has been cancelled
Validate dotnet / setup-version (8.0, ubuntu-latest) (push) Has been cancelled
Validate dotnet / setup-version (8.0, windows-latest) (push) Has been cancelled
Update configuration files / Update configuration files (push) Has been cancelled
88 lines
3.1 KiB
TypeScript
88 lines
3.1 KiB
TypeScript
import * as cache from '@actions/cache';
|
|
import * as core from '@actions/core';
|
|
import fs from 'node:fs';
|
|
import {run} from '../src/cache-save';
|
|
import {getNuGetFolderPath} from '../src/cache-utils';
|
|
|
|
jest.mock('@actions/cache');
|
|
jest.mock('@actions/core');
|
|
jest.mock('node:fs');
|
|
jest.mock('../src/cache-utils');
|
|
|
|
describe('cache-save tests', () => {
|
|
beforeAll(() => {
|
|
jest.mocked(getNuGetFolderPath).mockResolvedValue({
|
|
'global-packages': 'global-packages',
|
|
'http-cache': 'http-cache',
|
|
temp: 'temp',
|
|
'plugins-cache': 'plugins-cache'
|
|
});
|
|
});
|
|
beforeEach(() => {
|
|
jest.mocked(core.setFailed).mockClear();
|
|
jest.mocked(core.getState).mockClear();
|
|
jest.mocked(core.setOutput).mockClear();
|
|
jest.mocked(cache.saveCache).mockClear();
|
|
jest.mocked(fs.existsSync).mockClear();
|
|
});
|
|
|
|
it('does not save cache when inputs:cache === false', async () => {
|
|
jest.mocked(core.getBooleanInput).mockReturnValue(false);
|
|
|
|
await run();
|
|
|
|
expect(jest.mocked(core.setFailed)).not.toHaveBeenCalled();
|
|
expect(jest.mocked(core.getState)).not.toHaveBeenCalled();
|
|
expect(jest.mocked(fs.existsSync)).not.toHaveBeenCalled();
|
|
expect(jest.mocked(cache.saveCache)).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('does not save cache when core.getState("CACHE_KEY") returns ""', async () => {
|
|
jest.mocked(core.getBooleanInput).mockReturnValue(true);
|
|
jest.mocked(core.getState).mockReturnValue('');
|
|
|
|
await run();
|
|
|
|
expect(jest.mocked(core.setFailed)).not.toHaveBeenCalled();
|
|
expect(jest.mocked(core.getState)).toHaveBeenCalledTimes(2);
|
|
expect(jest.mocked(fs.existsSync)).not.toHaveBeenCalled();
|
|
expect(jest.mocked(cache.saveCache)).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('throws Error when cachePath not exists', async () => {
|
|
jest.mocked(core.getBooleanInput).mockReturnValue(true);
|
|
jest.mocked(core.getState).mockReturnValue('cache-key');
|
|
jest.mocked(fs.existsSync).mockReturnValue(false);
|
|
|
|
await run();
|
|
|
|
expect(jest.mocked(core.setFailed)).toHaveBeenCalled();
|
|
expect(jest.mocked(core.getState)).toHaveBeenCalledTimes(2);
|
|
expect(jest.mocked(cache.saveCache)).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('does not save cache when state.CACHE_KEY === state.CACHE_RESULT', async () => {
|
|
jest.mocked(core.getBooleanInput).mockReturnValue(true);
|
|
jest.mocked(core.getState).mockReturnValue('cache-key');
|
|
jest.mocked(fs.existsSync).mockReturnValue(true);
|
|
|
|
await run();
|
|
|
|
expect(jest.mocked(core.setFailed)).not.toHaveBeenCalled();
|
|
expect(jest.mocked(core.getState)).toHaveBeenCalledTimes(2);
|
|
expect(jest.mocked(cache.saveCache)).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('saves cache when state.CACHE_KEY !== state.CACHE_RESULT', async () => {
|
|
jest.mocked(core.getBooleanInput).mockReturnValue(true);
|
|
jest.mocked(core.getState).mockImplementation(s => s);
|
|
jest.mocked(fs.existsSync).mockReturnValue(true);
|
|
|
|
await run();
|
|
|
|
expect(jest.mocked(core.setFailed)).not.toHaveBeenCalled();
|
|
expect(jest.mocked(core.getState)).toHaveBeenCalledTimes(2);
|
|
expect(jest.mocked(cache.saveCache)).toHaveBeenCalled();
|
|
});
|
|
});
|