mirror of
https://gitea.com/actions/setup-java.git
synced 2025-04-06 23:39:37 +00:00
Default to runner architecture (#376)
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { MicrosoftDistributions } from '../../src/distributions/microsoft/installer';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import os from 'os';
|
||||
import data from '../../src/distributions/microsoft/microsoft-openjdk-versions.json';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import * as core from '@actions/core';
|
||||
@ -77,6 +77,30 @@ describe('findPackageForDownload', () => {
|
||||
expect(result.url).toBe(url);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['amd64', 'x64'],
|
||||
['arm64', 'aarch64']
|
||||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
async (osArch: string, distroArch: string) => {
|
||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||
|
||||
const version = '17';
|
||||
const distro = new MicrosoftDistributions({
|
||||
version,
|
||||
architecture: '', // to get default value
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
const result = await distro['findPackageForDownload'](version);
|
||||
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.3-linux-${distroArch}.tar.gz`;
|
||||
|
||||
expect(result.url).toBe(expectedUrl);
|
||||
}
|
||||
);
|
||||
|
||||
it('should throw an error', async () => {
|
||||
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
|
Reference in New Issue
Block a user