mirror of
https://github.com/actions/setup-node.git
synced 2026-03-04 06:51:04 +08:00
Compare commits
1 Commits
7e0a43fdfd
...
0b6e5029e4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b6e5029e4 |
@ -8,13 +8,9 @@ import * as utils from '../src/cache-utils';
|
||||
import {restoreCache} from '../src/cache-restore';
|
||||
|
||||
describe('cache-restore', () => {
|
||||
const packageManagers = ['yarn', 'npm', 'pnpm'] as const;
|
||||
type PackageManager = (typeof packageManagers)[number];
|
||||
|
||||
const setWorkspaceFor = (pm: PackageManager) => {
|
||||
const setWorkspaceFor = (pm: 'npm' | 'yarn' | 'pnpm') => {
|
||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data', pm);
|
||||
};
|
||||
const originalGithubWorkspace = process.env['GITHUB_WORKSPACE'];
|
||||
if (!process.env.RUNNER_OS) {
|
||||
process.env.RUNNER_OS = 'Linux';
|
||||
}
|
||||
@ -134,11 +130,11 @@ describe('cache-restore', () => {
|
||||
['yarn', '1.2.3', yarnFileHash],
|
||||
['npm', '', npmFileHash],
|
||||
['pnpm', '', pnpmFileHash]
|
||||
] as const)(
|
||||
])(
|
||||
'restored dependencies for %s',
|
||||
async (packageManager, toolVersion, fileHash) => {
|
||||
// Set workspace to the appropriate fixture folder
|
||||
setWorkspaceFor(packageManager);
|
||||
setWorkspaceFor(packageManager as 'npm' | 'yarn' | 'pnpm');
|
||||
getCommandOutputSpy.mockImplementation((command: string) => {
|
||||
if (command.includes('version')) {
|
||||
return toolVersion;
|
||||
@ -166,11 +162,11 @@ describe('cache-restore', () => {
|
||||
['yarn', '1.2.3', yarnFileHash],
|
||||
['npm', '', npmFileHash],
|
||||
['pnpm', '', pnpmFileHash]
|
||||
] as const)(
|
||||
])(
|
||||
'dependencies are changed %s',
|
||||
async (packageManager, toolVersion, fileHash) => {
|
||||
// Set workspace to the appropriate fixture folder
|
||||
setWorkspaceFor(packageManager);
|
||||
setWorkspaceFor(packageManager as 'npm' | 'yarn' | 'pnpm');
|
||||
getCommandOutputSpy.mockImplementation((command: string) => {
|
||||
if (command.includes('version')) {
|
||||
return toolVersion;
|
||||
@ -191,11 +187,6 @@ describe('cache-restore', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (originalGithubWorkspace === undefined) {
|
||||
delete process.env['GITHUB_WORKSPACE'];
|
||||
} else {
|
||||
process.env['GITHUB_WORKSPACE'] = originalGithubWorkspace;
|
||||
}
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user