Add arch default tests to all distros

...and update temurin's to test 2 architectures instead of 1.
This commit is contained in:
Wes Morgan 2022-09-20 10:03:12 -06:00
parent f83416a080
commit c041f7cce2
No known key found for this signature in database
GPG key ID: 5639E4CBFA17DC84
6 changed files with 174 additions and 18 deletions

View file

@ -1,4 +1,5 @@
import { MicrosoftDistributions } from '../../src/distributions/microsoft/installer';
import os from 'os';
describe('findPackageForDownload', () => {
let distribution: MicrosoftDistributions;
@ -61,6 +62,33 @@ 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);
const version = '17';
const distro = new MicrosoftDistributions({
version,
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
distribution['getPlatformOption'] = () => {
return { archive: 'tar.gz', os: 'macos' };
};
const result = await distro['findPackageForDownload'](version);
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.3-macos-${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 */