Stabilize JetBrains tests by removing external network dependency

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:
copilot-swe-agent[bot] 2026-04-20 14:54:35 +00:00 committed by GitHub
parent b622de1dfa
commit 219e4ee775
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,3 @@
import https from 'https';
import {HttpClient} from '@actions/http-client';
import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer';
@ -17,6 +16,11 @@ describe('getAvailableVersions', () => {
headers: {},
result: []
});
jest.spyOn(HttpClient.prototype, 'head').mockResolvedValue({
message: {
statusCode: 200
}
} as any);
// Mock core.error to suppress error logs
spyCoreError = jest.spyOn(core, 'error');
@ -84,14 +88,9 @@ describe('findPackageForDownload', () => {
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();
});
expect(resolvedVersion.url).toMatch(
/^https:\/\/cache-redirector\.jetbrains\.com\/intellij-jbr\//
);
}
);