mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 18:06:45 +00:00
Add tests for os.arch() default behavior
This commit is contained in:
parent
e169777d50
commit
c22bb804ce
2 changed files with 45 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
import { HttpClient } from '@actions/http-client';
|
||||
|
||||
import os from 'os';
|
||||
import {
|
||||
TemurinDistribution,
|
||||
TemurinImplementation
|
||||
|
@ -109,6 +109,30 @@ describe('getAvailableVersions', () => {
|
|||
expect(distribution.toolcacheFolderName).toBe(expected);
|
||||
}
|
||||
);
|
||||
|
||||
it('defaults to os.arch() mapped to temurin arch', async () => {
|
||||
jest.spyOn(os, 'arch').mockReturnValue('amd64');
|
||||
|
||||
const installerOptions: JavaInstallerOptions = {
|
||||
version: '17',
|
||||
architecture: '',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
};
|
||||
|
||||
const expectedParameters =
|
||||
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0';
|
||||
|
||||
const distribution = new TemurinDistribution(installerOptions, TemurinImplementation.Hotspot);
|
||||
const baseUrl = 'https://api.adoptium.net/v3/assets/version/%5B1.0,100.0%5D';
|
||||
const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptium&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
|
||||
distribution['getPlatformOption'] = () => 'mac';
|
||||
|
||||
await distribution['getAvailableVersions']();
|
||||
|
||||
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||
expect(spyHttpClient.mock.calls[0][0]).toBe(expectedUrl);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue