mirror of
				https://gitea.com/actions/cache.git
				synced 2025-10-31 07:47:07 +00:00 
			
		
		
		
	Add support to opt-in enable cross-os caching on windows (#1056)
* Add support to opt-in enable cross-os caching on windows * Fix tests * Address review comments and update tests * Fix tests * Address review comments * Address review comments
This commit is contained in:
		| @@ -27,9 +27,18 @@ beforeAll(() => { | ||||
|             return actualUtils.getInputAsArray(name, options); | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "getInputAsBool").mockImplementation( | ||||
|         (name, options) => { | ||||
|             return jest | ||||
|                 .requireActual("../src/utils/actionUtils") | ||||
|                 .getInputAsBool(name, options); | ||||
|         } | ||||
|     ); | ||||
| }); | ||||
|  | ||||
| beforeEach(() => { | ||||
|     jest.restoreAllMocks(); | ||||
|     process.env[Events.Key] = Events.Push; | ||||
|     process.env[RefKey] = "refs/heads/feature-branch"; | ||||
|  | ||||
| @@ -50,7 +59,8 @@ test("restore with no cache found", async () => { | ||||
|     const key = "node-test"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -65,7 +75,7 @@ test("restore with no cache found", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|  | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); | ||||
|     expect(outputMock).toHaveBeenCalledTimes(1); | ||||
| @@ -83,7 +93,8 @@ test("restore with restore keys and no cache found", async () => { | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         restoreKeys: [restoreKey] | ||||
|         restoreKeys: [restoreKey], | ||||
|         enableCrossOsArchive: false | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -98,7 +109,13 @@ test("restore with restore keys and no cache found", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
|         key, | ||||
|         [restoreKey], | ||||
|         {}, | ||||
|         false | ||||
|     ); | ||||
|  | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); | ||||
|     expect(failedMock).toHaveBeenCalledTimes(0); | ||||
| @@ -113,7 +130,8 @@ test("restore with cache found for key", async () => { | ||||
|     const key = "node-test"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -128,7 +146,7 @@ test("restore with cache found for key", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|  | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-hit", "true"); | ||||
| @@ -147,7 +165,8 @@ test("restore with cache found for restore key", async () => { | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         restoreKeys: [restoreKey] | ||||
|         restoreKeys: [restoreKey], | ||||
|         enableCrossOsArchive: false | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -162,7 +181,13 @@ test("restore with cache found for restore key", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
|         key, | ||||
|         [restoreKey], | ||||
|         {}, | ||||
|         false | ||||
|     ); | ||||
|  | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-hit", "false"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sampark Sharma
					Sampark Sharma