File tree Expand file tree Collapse file tree 5 files changed +21
-11
lines changed Expand file tree Collapse file tree 5 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,6 @@ describe('cache-restore', () => {
5353 let getCommandOutputSpy : jest . SpyInstance ;
5454 let restoreCacheSpy : jest . SpyInstance ;
5555 let hashFilesSpy : jest . SpyInstance ;
56- let inSpy : jest . SpyInstance ;
5756
5857 beforeEach ( ( ) => {
5958 // core
@@ -70,8 +69,6 @@ describe('cache-restore', () => {
7069 saveStateSpy . mockImplementation ( ( ) => undefined ) ;
7170
7271 inputs = { } ;
73- inSpy = jest . spyOn ( core , 'getInput' ) ;
74- inSpy . mockImplementation ( name => inputs [ name ] ) ;
7572
7673 // glob
7774 hashFilesSpy = jest . spyOn ( glob , 'hashFiles' ) ;
@@ -137,12 +134,11 @@ describe('cache-restore', () => {
137134 return findCacheFolder ( command ) ;
138135 }
139136 } ) ;
140- inputs [ 'node-version' ] = 'vABC' ;
141137
142138 await restoreCache ( packageManager , '' ) ;
143139 expect ( hashFilesSpy ) . toHaveBeenCalled ( ) ;
144140 expect ( infoSpy ) . toHaveBeenCalledWith (
145- `Cache restored from key: node-cache-${ platform } -${ packageManager } -v2-vABC- ${ fileHash } `
141+ `Cache restored from key: node-cache-${ platform } -${ packageManager } -${ fileHash } `
146142 ) ;
147143 expect ( infoSpy ) . not . toHaveBeenCalledWith (
148144 `${ packageManager } cache is not found`
Original file line number Diff line number Diff line change 66 PackageManagerInfo ,
77 isCacheFeatureAvailable ,
88 supportedPackageManagers ,
9- getCommandOutput
9+ getCommandOutput ,
10+ resetProjectDirectoriesMemoized
1011} from '../src/cache-utils' ;
1112import fs from 'fs' ;
1213import * as cacheUtils from '../src/cache-utils' ;
@@ -104,9 +105,7 @@ describe('cache-utils', () => {
104105 MockGlobber . create ( [ '/foo' , '/bar' ] )
105106 ) ;
106107
107- Object . keys ( expandedPatternsMemoized ) . forEach (
108- key => delete expandedPatternsMemoized [ key ]
109- ) ;
108+ resetProjectDirectoriesMemoized ( ) ;
110109 } ) ;
111110
112111 afterEach ( ( ) => {
Original file line number Diff line number Diff line change @@ -60434,7 +60434,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6043460434 return (mod && mod.__esModule) ? mod : { "default": mod };
6043560435};
6043660436Object.defineProperty(exports, "__esModule", ({ value: true }));
60437- exports.isCacheFeatureAvailable = exports.isGhes = exports.repoHasYarn3ManagedCache = exports.getCacheDirectories = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
60437+ exports.isCacheFeatureAvailable = exports.isGhes = exports.repoHasYarn3ManagedCache = exports.getCacheDirectories = exports.resetProjectDirectoriesMemoized = exports. getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
6043860438const core = __importStar(__nccwpck_require__(2186));
6043960439const exec = __importStar(__nccwpck_require__(1514));
6044060440const cache = __importStar(__nccwpck_require__(7799));
@@ -60511,6 +60511,11 @@ exports.getPackageManagerInfo = getPackageManagerInfo;
6051160511 * it contains expensive IO operation and thus should be memoized
6051260512 */
6051360513let projectDirectoriesMemoized = null;
60514+ /**
60515+ * unit test must reset memoized variables
60516+ */
60517+ const resetProjectDirectoriesMemoized = () => (projectDirectoriesMemoized = null);
60518+ exports.resetProjectDirectoriesMemoized = resetProjectDirectoriesMemoized;
6051460519/**
6051560520 * Expands (converts) the string input `cache-dependency-path` to list of directories that
6051660521 * may be project roots
Original file line number Diff line number Diff line change @@ -71220,7 +71220,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7122071220 return (mod && mod.__esModule) ? mod : { "default": mod };
7122171221};
7122271222Object.defineProperty(exports, "__esModule", ({ value: true }));
71223- exports.isCacheFeatureAvailable = exports.isGhes = exports.repoHasYarn3ManagedCache = exports.getCacheDirectories = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
71223+ exports.isCacheFeatureAvailable = exports.isGhes = exports.repoHasYarn3ManagedCache = exports.getCacheDirectories = exports.resetProjectDirectoriesMemoized = exports. getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
7122471224const core = __importStar(__nccwpck_require__(2186));
7122571225const exec = __importStar(__nccwpck_require__(1514));
7122671226const cache = __importStar(__nccwpck_require__(7799));
@@ -71297,6 +71297,11 @@ exports.getPackageManagerInfo = getPackageManagerInfo;
7129771297 * it contains expensive IO operation and thus should be memoized
7129871298 */
7129971299let projectDirectoriesMemoized = null;
71300+ /**
71301+ * unit test must reset memoized variables
71302+ */
71303+ const resetProjectDirectoriesMemoized = () => (projectDirectoriesMemoized = null);
71304+ exports.resetProjectDirectoriesMemoized = resetProjectDirectoriesMemoized;
7130071305/**
7130171306 * Expands (converts) the string input `cache-dependency-path` to list of directories that
7130271307 * may be project roots
Original file line number Diff line number Diff line change @@ -119,6 +119,11 @@ export const getPackageManagerInfo = async (packageManager: string) => {
119119 */
120120
121121let projectDirectoriesMemoized : string [ ] | null = null ;
122+ /**
123+ * unit test must reset memoized variables
124+ */
125+ export const resetProjectDirectoriesMemoized = ( ) =>
126+ ( projectDirectoriesMemoized = null ) ;
122127/**
123128 * Expands (converts) the string input `cache-dependency-path` to list of directories that
124129 * may be project roots
You can’t perform that action at this time.
0 commit comments