mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 02:16:45 +00:00
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:
parent
28233e2fcb
commit
53d9f2a017
4 changed files with 4355 additions and 4342 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue