mirror of
https://github.com/actions/setup-java.git
synced 2026-06-24 21:27:41 +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 {HttpClient} from '@actions/http-client';
|
||||||
import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer';
|
import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer';
|
||||||
|
|
||||||
@ -17,6 +16,11 @@ describe('getAvailableVersions', () => {
|
|||||||
headers: {},
|
headers: {},
|
||||||
result: []
|
result: []
|
||||||
});
|
});
|
||||||
|
jest.spyOn(HttpClient.prototype, 'head').mockResolvedValue({
|
||||||
|
message: {
|
||||||
|
statusCode: 200
|
||||||
|
}
|
||||||
|
} as any);
|
||||||
|
|
||||||
// Mock core.error to suppress error logs
|
// Mock core.error to suppress error logs
|
||||||
spyCoreError = jest.spyOn(core, 'error');
|
spyCoreError = jest.spyOn(core, 'error');
|
||||||
@ -84,14 +88,9 @@ describe('findPackageForDownload', () => {
|
|||||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
const resolvedVersion =
|
const resolvedVersion =
|
||||||
await distribution['findPackageForDownload'](input);
|
await distribution['findPackageForDownload'](input);
|
||||||
const url = resolvedVersion.url;
|
expect(resolvedVersion.url).toMatch(
|
||||||
const options = {method: 'HEAD'};
|
/^https:\/\/cache-redirector\.jetbrains\.com\/intellij-jbr\//
|
||||||
|
);
|
||||||
https.request(url, options, res => {
|
|
||||||
// JetBrains uses 403 for inexistent packages
|
|
||||||
expect(res.statusCode).not.toBe(403);
|
|
||||||
res.resume();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user