mirror of
				https://gitea.com/actions/setup-python.git
				synced 2025-10-29 07:47:14 +00:00 
			
		
		
		
	Fix: Add .zip extension to Windows package downloads for Expand-Archive Compatibility (#916)
				
					
				
			* Fix: specify filename during Windows package download * Changed unit test download urls
This commit is contained in:
		| @@ -12,7 +12,9 @@ import { | ||||
|   getVersionInputFromFile, | ||||
|   getVersionInputFromPlainFile, | ||||
|   getVersionInputFromTomlFile, | ||||
|   getNextPageUrl | ||||
|   getNextPageUrl, | ||||
|   IS_WINDOWS, | ||||
|   getDownloadFileName | ||||
| } from '../src/utils'; | ||||
|  | ||||
| jest.mock('@actions/cache'); | ||||
| @@ -159,3 +161,37 @@ describe('getNextPageUrl', () => { | ||||
|     expect(getNextPageUrl(generateResponse(page2Links))).toBeNull(); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| describe('getDownloadFileName', () => { | ||||
|   const originalEnv = process.env; | ||||
|   const tempDir = path.join(__dirname, 'runner', 'temp'); | ||||
|  | ||||
|   beforeEach(() => { | ||||
|     process.env = {...originalEnv}; | ||||
|   }); | ||||
|  | ||||
|   afterEach(() => { | ||||
|     process.env = originalEnv; | ||||
|   }); | ||||
|  | ||||
|   it('should return the correct path on Windows', () => { | ||||
|     if (IS_WINDOWS) { | ||||
|       process.env['RUNNER_TEMP'] = tempDir; | ||||
|       const downloadUrl = | ||||
|         'https://github.com/actions/sometool/releases/tag/1.2.3-20200402.6/sometool-1.2.3-win32-x64.zip'; | ||||
|       const expectedPath = path.join( | ||||
|         process.env.RUNNER_TEMP, | ||||
|         path.basename(downloadUrl) | ||||
|       ); | ||||
|       expect(getDownloadFileName(downloadUrl)).toBe(expectedPath); | ||||
|     } | ||||
|   }); | ||||
|  | ||||
|   it('should return undefined on non-Windows', () => { | ||||
|     if (!IS_WINDOWS) { | ||||
|       const downloadUrl = | ||||
|         'https://github.com/actions/sometool/releases/tag/1.2.3-20200402.6/sometool-1.2.3-linux-x64.tar.gz'; | ||||
|       expect(getDownloadFileName(downloadUrl)).toBeUndefined(); | ||||
|     } | ||||
|   }); | ||||
| }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Priya Gupta
					Priya Gupta