From 219e4ee7756900e5fa2399d4f0d8fe1223fb14db Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Apr 2026 14:54:35 +0000 Subject: [PATCH] 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> --- .../distributors/jetbrains-installer.test.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/__tests__/distributors/jetbrains-installer.test.ts b/__tests__/distributors/jetbrains-installer.test.ts index bf1dc15d..f8b70517 100644 --- a/__tests__/distributors/jetbrains-installer.test.ts +++ b/__tests__/distributors/jetbrains-installer.test.ts @@ -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\// + ); } );