mirror of
https://github.com/actions/setup-java.git
synced 2025-08-19 19:21:04 +00:00
fix tests
This commit is contained in:
parent
dc9eba32a7
commit
bb39e340a4
14 changed files with 72 additions and 18 deletions
|
@ -8,6 +8,10 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
|
|
||||||
import manifestData from '../data/adopt.json';
|
import manifestData from '../data/adopt.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
|
@ -191,7 +195,7 @@ describe('getAvailableVersions', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
|
|
||||||
const installerOptions: JavaInstallerOptions = {
|
const installerOptions: JavaInstallerOptions = {
|
||||||
version: '17',
|
version: '17',
|
||||||
|
|
|
@ -14,6 +14,10 @@ import {
|
||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
|
|
||||||
class EmptyJavaBase extends JavaBase {
|
class EmptyJavaBase extends JavaBase {
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
super('Empty', installerOptions);
|
super('Empty', installerOptions);
|
||||||
|
@ -287,7 +291,7 @@ describe('setupJava', () => {
|
||||||
spyCoreSetOutput = jest.spyOn(core, 'setOutput');
|
spyCoreSetOutput = jest.spyOn(core, 'setOutput');
|
||||||
spyCoreSetOutput.mockImplementation(() => undefined);
|
spyCoreSetOutput.mockImplementation(() => undefined);
|
||||||
|
|
||||||
jest.spyOn(os, 'arch').mockReturnValue('x86');
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture('x86'));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
|
@ -6,6 +6,10 @@ import * as util from '../../src/util';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import {isGeneratorFunction} from 'util/types';
|
import {isGeneratorFunction} from 'util/types';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
|
|
||||||
import manifestData from '../data/corretto.json';
|
import manifestData from '../data/corretto.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
|
@ -208,7 +212,7 @@ describe('getAvailableVersions', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
|
|
||||||
const version = '17';
|
const version = '17';
|
||||||
const installerOptions: JavaInstallerOptions = {
|
const installerOptions: JavaInstallerOptions = {
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
|
import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {getDownloadArchiveExtension} from '../../src/util';
|
import {getDownloadArchiveExtension} from '../../src/util';
|
||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
|
@ -103,7 +107,7 @@ describe('findPackageForDownload', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||||
|
|
||||||
const version = '21';
|
const version = '21';
|
||||||
|
|
|
@ -6,6 +6,10 @@ import {
|
||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
|
|
||||||
import manifestData from '../data/liberica.json';
|
import manifestData from '../data/liberica.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
|
@ -105,7 +109,7 @@ describe('getAvailableVersions', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
|
|
||||||
const distribution = new LibericaDistributions({
|
const distribution = new LibericaDistributions({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
|
|
@ -6,6 +6,10 @@ import {
|
||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
|
|
||||||
import manifestData from '../data/liberica-linux.json';
|
import manifestData from '../data/liberica-linux.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
|
@ -105,7 +109,7 @@ describe('getAvailableVersions', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
|
|
||||||
const distribution = new LibericaDistributions({
|
const distribution = new LibericaDistributions({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
|
|
@ -6,6 +6,10 @@ import {
|
||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
|
|
||||||
import manifestData from '../data/liberica-windows.json';
|
import manifestData from '../data/liberica-windows.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
|
@ -105,7 +109,7 @@ describe('getAvailableVersions', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
|
|
||||||
const distribution = new LibericaDistributions({
|
const distribution = new LibericaDistributions({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import {MicrosoftDistributions} from '../../src/distributions/microsoft/installer';
|
import {MicrosoftDistributions} from '../../src/distributions/microsoft/installer';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
import data from '../data/microsoft.json';
|
import data from '../data/microsoft.json';
|
||||||
import * as httpm from '@actions/http-client';
|
import * as httpm from '@actions/http-client';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
@ -95,7 +99,7 @@ describe('findPackageForDownload', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('darwin');
|
jest.spyOn(os, 'platform').mockReturnValue('darwin');
|
||||||
|
|
||||||
const version = '17';
|
const version = '17';
|
||||||
|
@ -119,7 +123,7 @@ describe('findPackageForDownload', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||||
|
|
||||||
const version = '17';
|
const version = '17';
|
||||||
|
@ -143,7 +147,7 @@ describe('findPackageForDownload', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32');
|
jest.spyOn(os, 'platform').mockReturnValue('win32');
|
||||||
|
|
||||||
const version = '17';
|
const version = '17';
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import {OracleDistribution} from '../../src/distributions/oracle/installer';
|
import {OracleDistribution} from '../../src/distributions/oracle/installer';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {getDownloadArchiveExtension} from '../../src/util';
|
import {getDownloadArchiveExtension} from '../../src/util';
|
||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
|
@ -95,7 +99,7 @@ describe('findPackageForDownload', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||||
|
|
||||||
const version = '18';
|
const version = '18';
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
import {
|
import {
|
||||||
TemurinDistribution,
|
TemurinDistribution,
|
||||||
TemurinImplementation
|
TemurinImplementation
|
||||||
|
@ -147,7 +151,7 @@ describe('getAvailableVersions', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(distroArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(distroArch));
|
||||||
|
|
||||||
const installerOptions: JavaInstallerOptions = {
|
const installerOptions: JavaInstallerOptions = {
|
||||||
version: '17',
|
version: '17',
|
||||||
|
|
|
@ -5,6 +5,10 @@ import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||||
import * as utils from '../../src/util';
|
import * as utils from '../../src/util';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
|
|
||||||
import manifestData from '../data/zulu-releases-default.json';
|
import manifestData from '../data/zulu-releases-default.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
|
@ -126,7 +130,7 @@ describe('getAvailableVersions', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
|
|
||||||
const distribution = new ZuluDistribution({
|
const distribution = new ZuluDistribution({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
|
|
@ -5,6 +5,10 @@ import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||||
import * as utils from '../../src/util';
|
import * as utils from '../../src/util';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
|
|
||||||
import manifestData from '../data/zulu-linux.json';
|
import manifestData from '../data/zulu-linux.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
|
@ -126,7 +130,7 @@ describe('getAvailableVersions', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
|
|
||||||
const distribution = new ZuluDistribution({
|
const distribution = new ZuluDistribution({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
|
|
@ -5,6 +5,10 @@ import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||||
import * as utils from '../../src/util';
|
import * as utils from '../../src/util';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||||
|
return arch as NodeJS.Architecture;
|
||||||
|
}
|
||||||
|
|
||||||
import manifestData from '../data/zulu-windows.json';
|
import manifestData from '../data/zulu-windows.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
|
@ -126,7 +130,7 @@ describe('getAvailableVersions', () => {
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||||
|
|
||||||
const distribution = new ZuluDistribution({
|
const distribution = new ZuluDistribution({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
|
|
@ -6,7 +6,8 @@ import * as io from '@actions/io';
|
||||||
import * as toolchains from '../src/toolchains';
|
import * as toolchains from '../src/toolchains';
|
||||||
import {M2_DIR, MVN_TOOLCHAINS_FILE} from '../src/constants';
|
import {M2_DIR, MVN_TOOLCHAINS_FILE} from '../src/constants';
|
||||||
|
|
||||||
const m2Dir = path.join(__dirname, M2_DIR);
|
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-java-test-'));
|
||||||
|
const m2Dir = path.join(tempDir, M2_DIR);
|
||||||
const toolchainsFile = path.join(m2Dir, MVN_TOOLCHAINS_FILE);
|
const toolchainsFile = path.join(m2Dir, MVN_TOOLCHAINS_FILE);
|
||||||
|
|
||||||
describe('toolchains tests', () => {
|
describe('toolchains tests', () => {
|
||||||
|
@ -16,7 +17,7 @@ describe('toolchains tests', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await io.rmRF(m2Dir);
|
await io.rmRF(m2Dir);
|
||||||
spyOSHomedir = jest.spyOn(os, 'homedir');
|
spyOSHomedir = jest.spyOn(os, 'homedir');
|
||||||
spyOSHomedir.mockReturnValue(__dirname);
|
spyOSHomedir.mockReturnValue(tempDir);
|
||||||
spyInfo = jest.spyOn(core, 'info');
|
spyInfo = jest.spyOn(core, 'info');
|
||||||
spyInfo.mockImplementation(() => null);
|
spyInfo.mockImplementation(() => null);
|
||||||
}, 300000);
|
}, 300000);
|
||||||
|
@ -24,6 +25,7 @@ describe('toolchains tests', () => {
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
try {
|
try {
|
||||||
await io.rmRF(m2Dir);
|
await io.rmRF(m2Dir);
|
||||||
|
await io.rmRF(tempDir);
|
||||||
} catch {
|
} catch {
|
||||||
console.log('Failed to remove test directories');
|
console.log('Failed to remove test directories');
|
||||||
}
|
}
|
||||||
|
@ -40,7 +42,7 @@ describe('toolchains tests', () => {
|
||||||
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
||||||
};
|
};
|
||||||
|
|
||||||
const altHome = path.join(__dirname, 'runner', 'toolchains');
|
const altHome = path.join(tempDir, 'runner', 'toolchains');
|
||||||
const altToolchainsFile = path.join(altHome, MVN_TOOLCHAINS_FILE);
|
const altToolchainsFile = path.join(altHome, MVN_TOOLCHAINS_FILE);
|
||||||
await io.rmRF(altHome); // ensure it doesn't already exist
|
await io.rmRF(altHome); // ensure it doesn't already exist
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue