mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 18:36:46 +00:00
Fix archive suffix for Windows.
This commit is contained in:
parent
2828873ff8
commit
f073089abe
4 changed files with 6679 additions and 74 deletions
|
@ -1,34 +1,4 @@
|
|||
import { MicrosoftDistributions } from '../../src/distributions/microsoft/installer';
|
||||
import { ArchitectureOptions } from '../../src/distributions/microsoft/models';
|
||||
|
||||
describe('getArchitectureOptions', () => {
|
||||
it.each([
|
||||
['x64', { bitness: '64', arch: 'x86' }],
|
||||
['aarch64', { bitness: '64', arch: 'arm' }]
|
||||
] as [string, ArchitectureOptions][])('parse architecture %s -> %s', (input, expected) => {
|
||||
const distributions = new MicrosoftDistributions({
|
||||
architecture: input,
|
||||
checkLatest: false,
|
||||
packageType: '',
|
||||
version: ''
|
||||
});
|
||||
|
||||
expect(distributions['getArchitectureOptions']()).toEqual(expected);
|
||||
});
|
||||
|
||||
it.each(['armv6', 's390x'])('not support architecture %s', input => {
|
||||
const distributions = new MicrosoftDistributions({
|
||||
architecture: input,
|
||||
checkLatest: false,
|
||||
packageType: '',
|
||||
version: ''
|
||||
});
|
||||
|
||||
expect(() => distributions['getArchitectureOptions']()).toThrow(
|
||||
/Architecture '\w+' is not supported\. Supported architectures: .*/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
let distribution: MicrosoftDistributions;
|
||||
|
@ -46,34 +16,39 @@ describe('findPackageForDownload', () => {
|
|||
[
|
||||
'17.x',
|
||||
'17.0.1',
|
||||
'https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-{{OS_TYPE}}-x64.tar.gz'
|
||||
'https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
|
||||
],
|
||||
[
|
||||
'16.0.x',
|
||||
'16.0.2',
|
||||
'https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-{{OS_TYPE}}-x64.tar.gz'
|
||||
'https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
|
||||
],
|
||||
[
|
||||
'11.0.13',
|
||||
'11.0.13',
|
||||
'https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-{{OS_TYPE}}-x64.tar.gz'
|
||||
'https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
|
||||
]
|
||||
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
|
||||
const result = await distribution['findPackageForDownload'](input);
|
||||
expect(result.version).toBe(expectedVersion);
|
||||
var os: string;
|
||||
var archive: string;
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
os = 'macos';
|
||||
archive = 'tar.gz';
|
||||
break;
|
||||
case 'win32':
|
||||
os = 'windows';
|
||||
archive = 'zip';
|
||||
break;
|
||||
default:
|
||||
os = process.platform.toString();
|
||||
archive = 'tar.gz';
|
||||
break;
|
||||
}
|
||||
expect(result.url).toBe(expectedUrl.replace('{{OS_TYPE}}', os));
|
||||
const url = expectedUrl.replace('{{OS_TYPE}}', os).replace('{{ARCHIVE_TYPE}}', archive);
|
||||
expect(result.url).toBe(url);
|
||||
});
|
||||
|
||||
it('should throw an error', async () => {
|
||||
|
@ -92,13 +67,14 @@ describe('getPlatformOption', () => {
|
|||
});
|
||||
|
||||
it.each([
|
||||
['linux', 'linux'],
|
||||
['darwin', 'macos'],
|
||||
['win32', 'windows']
|
||||
])('os version %s -> %s', (input, expected) => {
|
||||
['linux', 'tar.gz', 'linux'],
|
||||
['darwin', 'tar.gz', 'macos'],
|
||||
['win32', 'zip', 'windows']
|
||||
])('os version %s -> %s', (input, expectedArchive, expectedOs) => {
|
||||
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
expect(actual.archive).toEqual(expectedArchive);
|
||||
expect(actual.os).toEqual(expectedOs);
|
||||
});
|
||||
|
||||
it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd', 'solaris', 'cygwin'])(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue