@@ -28,9 +28,17 @@ beforeAll(() => {
2828 return actualUtils . getInputAsArray ( name , options ) ;
2929 }
3030 ) ;
31+
32+ jest . spyOn ( actionUtils , "getInputAsBool" ) . mockImplementation (
33+ ( name , options ) => {
34+ const actualUtils = jest . requireActual ( "../src/utils/actionUtils" ) ;
35+ return actualUtils . getInputAsBool ( name , options ) ;
36+ }
37+ ) ;
3138} ) ;
3239
3340beforeEach ( ( ) => {
41+ jest . restoreAllMocks ( ) ;
3442 process . env [ Events . Key ] = Events . Push ;
3543 process . env [ RefKey ] = "refs/heads/feature-branch" ;
3644
@@ -97,7 +105,8 @@ test("restore on GHES with AC available ", async () => {
97105 const key = "node-test" ;
98106 testUtils . setInputs ( {
99107 path : path ,
100- key
108+ key,
109+ enableCrossOsArchive : false
101110 } ) ;
102111
103112 const infoMock = jest . spyOn ( core , "info" ) ;
@@ -113,7 +122,7 @@ test("restore on GHES with AC available ", async () => {
113122 await run ( new StateProvider ( ) ) ;
114123
115124 expect ( restoreCacheMock ) . toHaveBeenCalledTimes ( 1 ) ;
116- expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] ) ;
125+ expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] , { } , false ) ;
117126
118127 expect ( stateMock ) . toHaveBeenCalledWith ( "CACHE_KEY" , key ) ;
119128 expect ( setCacheHitOutputMock ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -152,13 +161,20 @@ test("restore with too many keys should fail", async () => {
152161 testUtils . setInputs ( {
153162 path : path ,
154163 key,
155- restoreKeys
164+ restoreKeys,
165+ enableCrossOsArchive : false
156166 } ) ;
157167 const failedMock = jest . spyOn ( core , "setFailed" ) ;
158168 const restoreCacheMock = jest . spyOn ( cache , "restoreCache" ) ;
159169 await run ( new StateProvider ( ) ) ;
160170 expect ( restoreCacheMock ) . toHaveBeenCalledTimes ( 1 ) ;
161- expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , restoreKeys ) ;
171+ expect ( restoreCacheMock ) . toHaveBeenCalledWith (
172+ [ path ] ,
173+ key ,
174+ restoreKeys ,
175+ { } ,
176+ false
177+ ) ;
162178 expect ( failedMock ) . toHaveBeenCalledWith (
163179 `Key Validation Error: Keys are limited to a maximum of 10.`
164180 ) ;
@@ -169,13 +185,14 @@ test("restore with large key should fail", async () => {
169185 const key = "foo" . repeat ( 512 ) ; // Over the 512 character limit
170186 testUtils . setInputs ( {
171187 path : path ,
172- key
188+ key,
189+ enableCrossOsArchive : false
173190 } ) ;
174191 const failedMock = jest . spyOn ( core , "setFailed" ) ;
175192 const restoreCacheMock = jest . spyOn ( cache , "restoreCache" ) ;
176193 await run ( new StateProvider ( ) ) ;
177194 expect ( restoreCacheMock ) . toHaveBeenCalledTimes ( 1 ) ;
178- expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] ) ;
195+ expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] , { } , false ) ;
179196 expect ( failedMock ) . toHaveBeenCalledWith (
180197 `Key Validation Error: ${ key } cannot be larger than 512 characters.`
181198 ) ;
@@ -186,13 +203,14 @@ test("restore with invalid key should fail", async () => {
186203 const key = "comma,comma" ;
187204 testUtils . setInputs ( {
188205 path : path ,
189- key
206+ key,
207+ enableCrossOsArchive : false
190208 } ) ;
191209 const failedMock = jest . spyOn ( core , "setFailed" ) ;
192210 const restoreCacheMock = jest . spyOn ( cache , "restoreCache" ) ;
193211 await run ( new StateProvider ( ) ) ;
194212 expect ( restoreCacheMock ) . toHaveBeenCalledTimes ( 1 ) ;
195- expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] ) ;
213+ expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] , { } , false ) ;
196214 expect ( failedMock ) . toHaveBeenCalledWith (
197215 `Key Validation Error: ${ key } cannot contain commas.`
198216 ) ;
@@ -203,7 +221,8 @@ test("restore with no cache found", async () => {
203221 const key = "node-test" ;
204222 testUtils . setInputs ( {
205223 path : path ,
206- key
224+ key,
225+ enableCrossOsArchive : false
207226 } ) ;
208227
209228 const infoMock = jest . spyOn ( core , "info" ) ;
@@ -218,7 +237,7 @@ test("restore with no cache found", async () => {
218237 await run ( new StateProvider ( ) ) ;
219238
220239 expect ( restoreCacheMock ) . toHaveBeenCalledTimes ( 1 ) ;
221- expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] ) ;
240+ expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] , { } , false ) ;
222241
223242 expect ( stateMock ) . toHaveBeenCalledWith ( "CACHE_KEY" , key ) ;
224243 expect ( failedMock ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -235,7 +254,8 @@ test("restore with restore keys and no cache found", async () => {
235254 testUtils . setInputs ( {
236255 path : path ,
237256 key,
238- restoreKeys : [ restoreKey ]
257+ restoreKeys : [ restoreKey ] ,
258+ enableCrossOsArchive : false
239259 } ) ;
240260
241261 const infoMock = jest . spyOn ( core , "info" ) ;
@@ -250,7 +270,13 @@ test("restore with restore keys and no cache found", async () => {
250270 await run ( new StateProvider ( ) ) ;
251271
252272 expect ( restoreCacheMock ) . toHaveBeenCalledTimes ( 1 ) ;
253- expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ restoreKey ] ) ;
273+ expect ( restoreCacheMock ) . toHaveBeenCalledWith (
274+ [ path ] ,
275+ key ,
276+ [ restoreKey ] ,
277+ { } ,
278+ false
279+ ) ;
254280
255281 expect ( stateMock ) . toHaveBeenCalledWith ( "CACHE_KEY" , key ) ;
256282 expect ( failedMock ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -265,7 +291,8 @@ test("restore with cache found for key", async () => {
265291 const key = "node-test" ;
266292 testUtils . setInputs ( {
267293 path : path ,
268- key
294+ key,
295+ enableCrossOsArchive : false
269296 } ) ;
270297
271298 const infoMock = jest . spyOn ( core , "info" ) ;
@@ -281,7 +308,7 @@ test("restore with cache found for key", async () => {
281308 await run ( new StateProvider ( ) ) ;
282309
283310 expect ( restoreCacheMock ) . toHaveBeenCalledTimes ( 1 ) ;
284- expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] ) ;
311+ expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ ] , { } , false ) ;
285312
286313 expect ( stateMock ) . toHaveBeenCalledWith ( "CACHE_KEY" , key ) ;
287314 expect ( setCacheHitOutputMock ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -298,7 +325,8 @@ test("restore with cache found for restore key", async () => {
298325 testUtils . setInputs ( {
299326 path : path ,
300327 key,
301- restoreKeys : [ restoreKey ]
328+ restoreKeys : [ restoreKey ] ,
329+ enableCrossOsArchive : false
302330 } ) ;
303331
304332 const infoMock = jest . spyOn ( core , "info" ) ;
@@ -314,7 +342,13 @@ test("restore with cache found for restore key", async () => {
314342 await run ( new StateProvider ( ) ) ;
315343
316344 expect ( restoreCacheMock ) . toHaveBeenCalledTimes ( 1 ) ;
317- expect ( restoreCacheMock ) . toHaveBeenCalledWith ( [ path ] , key , [ restoreKey ] ) ;
345+ expect ( restoreCacheMock ) . toHaveBeenCalledWith (
346+ [ path ] ,
347+ key ,
348+ [ restoreKey ] ,
349+ { } ,
350+ false
351+ ) ;
318352
319353 expect ( stateMock ) . toHaveBeenCalledWith ( "CACHE_KEY" , key ) ;
320354 expect ( setCacheHitOutputMock ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments