mirror of
https://github.com/actions/setup-java.git
synced 2026-06-17 08:54:24 +00:00
Add JetBrains fallback tests and tighten URL assertions
Agent-Logs-Url: https://github.com/AKB0700/setup-java/sessions/b5ff7a8f-7d53-4825-9148-a3d7b9163aac Co-authored-by: AKB0700 <157992575+AKB0700@users.noreply.github.com>
This commit is contained in:
parent
219e4ee775
commit
3ffaf5bec1
@ -54,6 +54,61 @@ describe('getAvailableVersions', () => {
|
||||
os.platform() === 'win32' ? manifestData.length : manifestData.length + 2;
|
||||
expect(availableVersions.length).toBe(length);
|
||||
}, 10_000);
|
||||
|
||||
it('uses _nomod package URL when base package is unavailable', async () => {
|
||||
spyHttpClient.mockReturnValueOnce({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: [{tag_name: 'jbr-release-21.0.3b465.3', prerelease: true}] as any
|
||||
});
|
||||
spyHttpClient.mockReturnValueOnce({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: []
|
||||
});
|
||||
jest
|
||||
.spyOn(HttpClient.prototype, 'head')
|
||||
.mockResolvedValueOnce({message: {statusCode: 404}} as any)
|
||||
.mockResolvedValueOnce({message: {statusCode: 200}} as any);
|
||||
|
||||
const distribution = new JetBrainsDistribution({
|
||||
version: '21-ea',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const availableVersions = await distribution['getAvailableVersions']();
|
||||
|
||||
expect(availableVersions).toHaveLength(1);
|
||||
expect(availableVersions[0].url).toContain('_nomod-21.0.3-linux-x64-b465.3');
|
||||
});
|
||||
|
||||
it('filters out versions when both package URLs are unavailable', async () => {
|
||||
spyHttpClient.mockReturnValueOnce({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: [{tag_name: 'jbr-release-21.0.3b465.3', prerelease: true}] as any
|
||||
});
|
||||
spyHttpClient.mockReturnValueOnce({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: []
|
||||
});
|
||||
jest
|
||||
.spyOn(HttpClient.prototype, 'head')
|
||||
.mockResolvedValueOnce({message: {statusCode: 404}} as any)
|
||||
.mockResolvedValueOnce({message: {statusCode: 404}} as any);
|
||||
|
||||
const distribution = new JetBrainsDistribution({
|
||||
version: '21-ea',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const availableVersions = await distribution['getAvailableVersions']();
|
||||
|
||||
expect(availableVersions).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
@ -89,7 +144,7 @@ describe('findPackageForDownload', () => {
|
||||
const resolvedVersion =
|
||||
await distribution['findPackageForDownload'](input);
|
||||
expect(resolvedVersion.url).toMatch(
|
||||
/^https:\/\/cache-redirector\.jetbrains\.com\/intellij-jbr\//
|
||||
/^https:\/\/cache-redirector\.jetbrains\.com\/intellij-jbr\/.+-b\d+(\.\d+)?\.tar\.gz$/
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user