mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 02:16:45 +00:00
Favor spy with preloaded data over actual download
This commit is contained in:
parent
cced1ea888
commit
a0d1026612
3 changed files with 1208 additions and 5 deletions
|
@ -1,12 +1,30 @@
|
|||
import { HttpClient } from '@actions/http-client';
|
||||
|
||||
import { CorettoDistribution } from '../../src/distributions/corretto/installer';
|
||||
import { JavaInstallerOptions } from '../../src/distributions/base-models';
|
||||
import * as util from '../../src/util';
|
||||
|
||||
const manifestData = require('../data/corretto.json') as [];
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
beforeEach(() => {});
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
|
||||
afterEach(() => {});
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
spyHttpClient.mockReturnValue({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: manifestData
|
||||
});
|
||||
spyGetDownloadArchiveExtension = jest.spyOn(util, 'getDownloadArchiveExtension');
|
||||
spyGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('load available versions', async () => {
|
||||
const distribution = new CorettoDistribution({
|
||||
|
@ -15,6 +33,7 @@ describe('getAvailableVersions', () => {
|
|||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
distribution['getPlatformOption'] = () => 'linux';
|
||||
|
||||
const availableVersions = await distribution['getAvailableVersions']();
|
||||
expect(availableVersions).not.toBeNull();
|
||||
|
@ -23,11 +42,12 @@ describe('getAvailableVersions', () => {
|
|||
|
||||
it('find package for download', async () => {
|
||||
const distribution = new CorettoDistribution({
|
||||
version: '11',
|
||||
version: '15',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
distribution['getPlatformOption'] = () => 'linux';
|
||||
|
||||
const availableVersion = await distribution['findPackageForDownload']('15');
|
||||
expect(availableVersion).not.toBeNull();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue