Fix PR Issues

- Fix JDK 11 URL Bug
- Add JDK URL Testing to ensure versions can be downloaded
- Run Prettier
This commit is contained in:
Gregory Mitchell 2024-10-13 20:23:43 -05:00
parent 28233e2fcb
commit 53d9f2a017
No known key found for this signature in database
GPG key ID: 771A6C995A086B84
4 changed files with 4355 additions and 4342 deletions

View file

@ -1,8 +1,6 @@
import https from 'https';
import {HttpClient} from '@actions/http-client';
import os from 'os';
import fs from 'fs';
import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer';
import {JavaInstallerOptions} from '../../src/distributions/base-models';
import manifestData from '../data/jetbrains.json';
@ -64,28 +62,48 @@ describe('findPackageForDownload', () => {
['21', '21.0.3+465.3'],
['x', '21.0.3+465.3']
])('version is resolved correctly %s -> %s', async (input, expected) => {
const distribution = new JetBrainsDistribution(
{
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
);
const distribution = new JetBrainsDistribution({
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload'](input);
expect(resolvedVersion.version).toBe(expected);
});
it('version is not found', async () => {
const distribution = new JetBrainsDistribution(
{
version: '8.0.452',
it.each(['17', '11.0', '11.0.11', '21.0.2', '21'])(
'version %s can be downloaded',
async input => {
const distribution = new JetBrainsDistribution({
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
);
});
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload'](
input
);
const url = resolvedVersion.url;
const options = {method: 'HEAD'};
https.request(url, options, res => {
// JetBrains uses 403 for inexistent packages
expect(res.statusCode).not.toBe(403);
res.resume();
});
}
);
it('version is not found', async () => {
const distribution = new JetBrainsDistribution({
version: '8.0.452',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(distribution['findPackageForDownload']('8.x')).rejects.toThrow(
/Could not find satisfied version for SemVer */
@ -93,14 +111,12 @@ describe('findPackageForDownload', () => {
});
it('version list is empty', async () => {
const distribution = new JetBrainsDistribution(
{
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
);
const distribution = new JetBrainsDistribution({
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => [];
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
/Could not find satisfied version for SemVer */