Favor spy with preloaded data over actual download
This commit is contained in:
parent
cced1ea888
commit
a0d1026612
1183
__tests__/data/corretto.json
Normal file
1183
__tests__/data/corretto.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,30 @@
|
|||||||
import { HttpClient } from '@actions/http-client';
|
import { HttpClient } from '@actions/http-client';
|
||||||
|
|
||||||
import { CorettoDistribution } from '../../src/distributions/corretto/installer';
|
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', () => {
|
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 () => {
|
it('load available versions', async () => {
|
||||||
const distribution = new CorettoDistribution({
|
const distribution = new CorettoDistribution({
|
||||||
@ -15,6 +33,7 @@ describe('getAvailableVersions', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
|
distribution['getPlatformOption'] = () => 'linux';
|
||||||
|
|
||||||
const availableVersions = await distribution['getAvailableVersions']();
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
expect(availableVersions).not.toBeNull();
|
expect(availableVersions).not.toBeNull();
|
||||||
@ -23,11 +42,12 @@ describe('getAvailableVersions', () => {
|
|||||||
|
|
||||||
it('find package for download', async () => {
|
it('find package for download', async () => {
|
||||||
const distribution = new CorettoDistribution({
|
const distribution = new CorettoDistribution({
|
||||||
version: '11',
|
version: '15',
|
||||||
architecture: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
|
distribution['getPlatformOption'] = () => 'linux';
|
||||||
|
|
||||||
const availableVersion = await distribution['findPackageForDownload']('15');
|
const availableVersion = await distribution['findPackageForDownload']('15');
|
||||||
expect(availableVersion).not.toBeNull();
|
expect(availableVersion).not.toBeNull();
|
||||||
|
@ -122,7 +122,7 @@ export class CorettoDistribution extends JavaBase {
|
|||||||
// Coretto has its own platform names so we need to map them
|
// Coretto has its own platform names so we need to map them
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'mac';
|
return 'macos';
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'windows';
|
return 'windows';
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user