mirror of
https://github.com/actions/setup-java.git
synced 2026-06-17 00:45:55 +00:00
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:
parent
b622de1dfa
commit
219e4ee775
@ -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\//
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user