mirror of
https://code.forgejo.org/actions/setup-python
synced 2025-06-08 04:18:19 +02: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:
parent
04c1311429
commit
036a523674
5 changed files with 77 additions and 8 deletions
|
@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue