1
0
Fork 0
mirror of https://code.forgejo.org/actions/setup-python synced 2025-06-15 15:34:14 +02:00

Fix: specify filename during Windows package download

This commit is contained in:
Priyagupta108 2024-07-25 20:54:42 +05:30
parent 04c1311429
commit 4dc2ed4b2a
5 changed files with 75 additions and 8 deletions

View file

@ -12,7 +12,9 @@ import {
getVersionInputFromFile,
getVersionInputFromPlainFile,
getVersionInputFromTomlFile,
getNextPageUrl
getNextPageUrl,
IS_WINDOWS,
getDownloadFileName
} from '../src/utils';
jest.mock('@actions/cache');
@ -159,3 +161,35 @@ 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://example.com/file.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://example.com/file.tar.gz';
expect(getDownloadFileName(downloadUrl)).toBeUndefined();
}
});
});