mirror of
https://gitea.com/actions/setup-node.git
synced 2025-12-14 20:51:39 +08:00
Merge 8454a14c98 into eff380dfbc
This commit is contained in:
@@ -2,16 +2,15 @@ import * as core from '@actions/core';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as path from 'path';
|
||||
import * as glob from '@actions/glob';
|
||||
import osm from 'os';
|
||||
|
||||
import * as utils from '../src/cache-utils';
|
||||
import {restoreCache} from '../src/cache-restore';
|
||||
|
||||
describe('cache-restore', () => {
|
||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||
if (!process.env.RUNNER_OS) {
|
||||
process.env.RUNNER_OS = 'Linux';
|
||||
}
|
||||
const platform = process.env.RUNNER_OS;
|
||||
const platform = 'Linux';
|
||||
const arch = 'arm64';
|
||||
const commonPath = '/some/random/path';
|
||||
const npmCachePath = `${commonPath}/npm`;
|
||||
const pnpmCachePath = `${commonPath}/pnpm`;
|
||||
@@ -52,6 +51,8 @@ describe('cache-restore', () => {
|
||||
let getCommandOutputSpy: jest.SpyInstance;
|
||||
let restoreCacheSpy: jest.SpyInstance;
|
||||
let hashFilesSpy: jest.SpyInstance;
|
||||
let archSpy: jest.SpyInstance;
|
||||
let platformSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
// core
|
||||
@@ -102,6 +103,13 @@ describe('cache-restore', () => {
|
||||
|
||||
// cache-utils
|
||||
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
||||
|
||||
// os
|
||||
archSpy = jest.spyOn(osm, 'arch');
|
||||
archSpy.mockImplementation(() => arch);
|
||||
|
||||
platformSpy = jest.spyOn(osm, 'platform');
|
||||
platformSpy.mockImplementation(() => platform);
|
||||
});
|
||||
|
||||
describe('Validate provided package manager', () => {
|
||||
@@ -135,7 +143,7 @@ describe('cache-restore', () => {
|
||||
await restoreCache(packageManager, '');
|
||||
expect(hashFilesSpy).toHaveBeenCalled();
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
`Cache restored from key: node-cache-${platform}-${packageManager}-${fileHash}`
|
||||
`Cache restored from key: node-cache-${platform}-${arch}-${packageManager}-${fileHash}`
|
||||
);
|
||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||
`${packageManager} cache is not found`
|
||||
|
||||
Reference in New Issue
Block a user