mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 02:16:45 +00:00
fix tests
This commit is contained in:
parent
fc1780360a
commit
f20fd4754a
5 changed files with 73 additions and 53 deletions
4
.github/workflows/e2e-publishing.yml
vendored
4
.github/workflows/e2e-publishing.yml
vendored
|
@ -26,6 +26,8 @@ jobs:
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
|
java-version: 'adopt'
|
||||||
|
distribution: '11'
|
||||||
server-id: maven
|
server-id: maven
|
||||||
server-username: MAVEN_USERNAME
|
server-username: MAVEN_USERNAME
|
||||||
server-password: MAVEN_CENTRAL_TOKEN
|
server-password: MAVEN_CENTRAL_TOKEN
|
||||||
|
@ -65,6 +67,8 @@ jobs:
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
|
java-version: 'adopt'
|
||||||
|
distribution: '11'
|
||||||
server-id: maven
|
server-id: maven
|
||||||
server-username: MAVEN_USERNAME
|
server-username: MAVEN_USERNAME
|
||||||
server-password: MAVEN_CENTRAL_TOKEN
|
server-password: MAVEN_CENTRAL_TOKEN
|
||||||
|
|
|
@ -27,19 +27,19 @@ describe('getAvailableVersions', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
{ version: '11', arch: 'x64', packageType: 'jdk' },
|
{ version: '11', architecture: 'x64', packageType: 'jdk' },
|
||||||
'os=mac&architecture=x64&image_type=jdk&release_type=ga&page_size=20&page=0'
|
'os=mac&architecture=x64&image_type=jdk&release_type=ga&page_size=20&page=0'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11', arch: 'x86', packageType: 'jdk' },
|
{ version: '11', architecture: 'x86', packageType: 'jdk' },
|
||||||
'os=mac&architecture=x86&image_type=jdk&release_type=ga&page_size=20&page=0'
|
'os=mac&architecture=x86&image_type=jdk&release_type=ga&page_size=20&page=0'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11', arch: 'x64', packageType: 'jre' },
|
{ version: '11', architecture: 'x64', packageType: 'jre' },
|
||||||
'os=mac&architecture=x64&image_type=jre&release_type=ga&page_size=20&page=0'
|
'os=mac&architecture=x64&image_type=jre&release_type=ga&page_size=20&page=0'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11-ea', arch: 'x64', packageType: 'jdk' },
|
{ version: '11-ea', architecture: 'x64', packageType: 'jdk' },
|
||||||
'os=mac&architecture=x64&image_type=jdk&release_type=ea&page_size=20&page=0'
|
'os=mac&architecture=x64&image_type=jdk&release_type=ea&page_size=20&page=0'
|
||||||
]
|
]
|
||||||
])(
|
])(
|
||||||
|
@ -78,7 +78,7 @@ describe('getAvailableVersions', () => {
|
||||||
|
|
||||||
const distribution = new AdoptDistribution({
|
const distribution = new AdoptDistribution({
|
||||||
version: '11',
|
version: '11',
|
||||||
arch: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk'
|
packageType: 'jdk'
|
||||||
});
|
});
|
||||||
const availableVersions = await distribution['getAvailableVersions']();
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
|
@ -103,7 +103,7 @@ describe('findPackageForDownload', () => {
|
||||||
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
||||||
const distribution = new AdoptDistribution({
|
const distribution = new AdoptDistribution({
|
||||||
version: '11',
|
version: '11',
|
||||||
arch: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk'
|
packageType: 'jdk'
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
@ -114,7 +114,7 @@ describe('findPackageForDownload', () => {
|
||||||
it('version is found but binaries list is empty', async () => {
|
it('version is found but binaries list is empty', async () => {
|
||||||
const distribution = new AdoptDistribution({
|
const distribution = new AdoptDistribution({
|
||||||
version: '11',
|
version: '11',
|
||||||
arch: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk'
|
packageType: 'jdk'
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
@ -126,7 +126,7 @@ describe('findPackageForDownload', () => {
|
||||||
it('version is not found', async () => {
|
it('version is not found', async () => {
|
||||||
const distribution = new AdoptDistribution({
|
const distribution = new AdoptDistribution({
|
||||||
version: '11',
|
version: '11',
|
||||||
arch: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk'
|
packageType: 'jdk'
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
@ -138,7 +138,7 @@ describe('findPackageForDownload', () => {
|
||||||
it('version list is empty', async () => {
|
it('version list is empty', async () => {
|
||||||
const distribution = new AdoptDistribution({
|
const distribution = new AdoptDistribution({
|
||||||
version: '11',
|
version: '11',
|
||||||
arch: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk'
|
packageType: 'jdk'
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => [];
|
distribution['getAvailableVersions'] = async () => [];
|
||||||
|
|
|
@ -58,21 +58,21 @@ describe('findInToolcache', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
{ version: '11', arch: 'x64', packageType: 'jdk' },
|
{ version: '11', architecture: 'x64', packageType: 'jdk' },
|
||||||
{ version: actualJavaVersion, path: javaPath }
|
{ version: actualJavaVersion, path: javaPath }
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11.1', arch: 'x64', packageType: 'jdk' },
|
{ version: '11.1', architecture: 'x64', packageType: 'jdk' },
|
||||||
{ version: actualJavaVersion, path: javaPath }
|
{ version: actualJavaVersion, path: javaPath }
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11.1.10', arch: 'x64', packageType: 'jdk' },
|
{ version: '11.1.10', architecture: 'x64', packageType: 'jdk' },
|
||||||
{ version: actualJavaVersion, path: javaPath }
|
{ version: actualJavaVersion, path: javaPath }
|
||||||
],
|
],
|
||||||
[{ version: '11', arch: 'x64', packageType: 'jre' }, null],
|
[{ version: '11', architecture: 'x64', packageType: 'jre' }, null],
|
||||||
[{ version: '8', arch: 'x64', packageType: 'jdk' }, null],
|
[{ version: '8', architecture: 'x64', packageType: 'jdk' }, null],
|
||||||
[{ version: '11', arch: 'x86', packageType: 'jdk' }, null],
|
[{ version: '11', architecture: 'x86', packageType: 'jdk' }, null],
|
||||||
[{ version: '11', arch: 'x86', packageType: 'jre' }, null]
|
[{ version: '11', architecture: 'x86', packageType: 'jre' }, null]
|
||||||
])(`should find java for path %s -> %s`, (input, expected) => {
|
])(`should find java for path %s -> %s`, (input, expected) => {
|
||||||
spyTcFindAllVersions.mockReturnValue([actualJavaVersion]);
|
spyTcFindAllVersions.mockReturnValue([actualJavaVersion]);
|
||||||
spyGetToolcachePath.mockImplementation(
|
spyGetToolcachePath.mockImplementation(
|
||||||
|
@ -115,7 +115,7 @@ describe('findInToolcache', () => {
|
||||||
(toolname: string, javaVersion: string, architecture: string) =>
|
(toolname: string, javaVersion: string, architecture: string) =>
|
||||||
`/hostedtoolcache/${toolname}/${javaVersion}/${architecture}`
|
`/hostedtoolcache/${toolname}/${javaVersion}/${architecture}`
|
||||||
);
|
);
|
||||||
mockJavaBase = new EmptyJavaBase({ version: input, arch: 'x64', packageType: 'jdk' });
|
mockJavaBase = new EmptyJavaBase({ version: input, architecture: 'x64', packageType: 'jdk' });
|
||||||
const foundVersion = mockJavaBase['findInToolcache']();
|
const foundVersion = mockJavaBase['findInToolcache']();
|
||||||
expect(foundVersion?.version).toEqual(expected);
|
expect(foundVersion?.version).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
@ -177,15 +177,15 @@ describe('setupJava', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
{ version: '11', arch: 'x86', packageType: 'jdk' },
|
{ version: '11', architecture: 'x86', packageType: 'jdk' },
|
||||||
{ version: actualJavaVersion, path: javaPath }
|
{ version: actualJavaVersion, path: javaPath }
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11.1', arch: 'x86', packageType: 'jdk' },
|
{ version: '11.1', architecture: 'x86', packageType: 'jdk' },
|
||||||
{ version: actualJavaVersion, path: javaPath }
|
{ version: actualJavaVersion, path: javaPath }
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11.1.10', arch: 'x86', packageType: 'jdk' },
|
{ version: '11.1.10', architecture: 'x86', packageType: 'jdk' },
|
||||||
{ version: actualJavaVersion, path: javaPath }
|
{ version: actualJavaVersion, path: javaPath }
|
||||||
]
|
]
|
||||||
])('should find java locally for %s', (input, expected) => {
|
])('should find java locally for %s', (input, expected) => {
|
||||||
|
@ -196,15 +196,15 @@ describe('setupJava', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
{ version: '11', arch: 'x86', packageType: 'jre' },
|
{ version: '11', architecture: 'x86', packageType: 'jre' },
|
||||||
{ path: `/toolcache/Java_Empty_jre/11.0.8/x86`, version: '11.0.8' }
|
{ path: `/toolcache/Java_Empty_jre/11.0.8/x86`, version: '11.0.8' }
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11', arch: 'x64', packageType: 'jdk' },
|
{ version: '11', architecture: 'x64', packageType: 'jdk' },
|
||||||
{ path: `/toolcache/Java_Empty_jdk/11.0.8/x64`, version: '11.0.8' }
|
{ path: `/toolcache/Java_Empty_jdk/11.0.8/x64`, version: '11.0.8' }
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11', arch: 'x64', packageType: 'jre' },
|
{ version: '11', architecture: 'x64', packageType: 'jre' },
|
||||||
{ path: `/toolcache/Java_Empty_jre/11.0.8/x64`, version: '11.0.8' }
|
{ path: `/toolcache/Java_Empty_jre/11.0.8/x64`, version: '11.0.8' }
|
||||||
]
|
]
|
||||||
])('download java with configuration %s', async (input, expected) => {
|
])('download java with configuration %s', async (input, expected) => {
|
||||||
|
@ -217,8 +217,8 @@ describe('setupJava', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[{ version: '15', arch: 'x86', packageType: 'jre' }],
|
[{ version: '15', architecture: 'x86', packageType: 'jre' }],
|
||||||
[{ version: '11.0.7', arch: 'x64', packageType: 'jre' }]
|
[{ version: '11.0.7', architecture: 'x64', packageType: 'jre' }]
|
||||||
])('should throw an error for Available version not found for %s', async input => {
|
])('should throw an error for Available version not found for %s', async input => {
|
||||||
mockJavaBase = new EmptyJavaBase(input);
|
mockJavaBase = new EmptyJavaBase(input);
|
||||||
await expect(mockJavaBase.setupJava()).rejects.toThrowError('Available version not found');
|
await expect(mockJavaBase.setupJava()).rejects.toThrowError('Available version not found');
|
||||||
|
|
|
@ -93,11 +93,11 @@ describe('setupJava', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('java is resolved from toolcache, jdkfile is untouched', async () => {
|
it('java is resolved from toolcache, jdkfile is untouched', async () => {
|
||||||
const inputs = { version: actualJavaVersion, arch: 'x86', packageType: 'jdk' };
|
const inputs = { version: actualJavaVersion, architecture: 'x86', packageType: 'jdk' };
|
||||||
const jdkFile = 'not_existing_one';
|
const jdkFile = 'not_existing_one';
|
||||||
const expected = {
|
const expected = {
|
||||||
version: actualJavaVersion,
|
version: actualJavaVersion,
|
||||||
path: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch)
|
path: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture)
|
||||||
};
|
};
|
||||||
|
|
||||||
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
||||||
|
@ -110,11 +110,11 @@ describe('setupJava', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("java is resolved from toolcache, jdkfile doesn't exist", async () => {
|
it("java is resolved from toolcache, jdkfile doesn't exist", async () => {
|
||||||
const inputs = { version: actualJavaVersion, arch: 'x86', packageType: 'jdk' };
|
const inputs = { version: actualJavaVersion, architecture: 'x86', packageType: 'jdk' };
|
||||||
const jdkFile = undefined;
|
const jdkFile = undefined;
|
||||||
const expected = {
|
const expected = {
|
||||||
version: actualJavaVersion,
|
version: actualJavaVersion,
|
||||||
path: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch)
|
path: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture)
|
||||||
};
|
};
|
||||||
|
|
||||||
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
||||||
|
@ -127,11 +127,11 @@ describe('setupJava', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('java is unpacked from jdkfile', async () => {
|
it('java is unpacked from jdkfile', async () => {
|
||||||
const inputs = { version: '11.0.289', arch: 'x86', packageType: 'jdk' };
|
const inputs = { version: '11.0.289', architecture: 'x86', packageType: 'jdk' };
|
||||||
const jdkFile = expectedJdkFile;
|
const jdkFile = expectedJdkFile;
|
||||||
const expected = {
|
const expected = {
|
||||||
version: '11.0.289',
|
version: '11.0.289',
|
||||||
path: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch)
|
path: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture)
|
||||||
};
|
};
|
||||||
|
|
||||||
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
||||||
|
@ -147,15 +147,15 @@ describe('setupJava', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('jdk file is not found', async () => {
|
it('jdk file is not found', async () => {
|
||||||
const inputs = { version: '11.0.289', arch: 'x86', packageType: 'jdk' };
|
const inputs = { version: '11.0.289', architecture: 'x86', packageType: 'jdk' };
|
||||||
const jdkFile = 'not_existing_one';
|
const jdkFile = 'not_existing_one';
|
||||||
const expected = {
|
const expected = {
|
||||||
javaVersion: '11.0.289',
|
javaVersion: '11.0.289',
|
||||||
javaPath: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch)
|
javaPath: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture)
|
||||||
};
|
};
|
||||||
|
|
||||||
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
||||||
expected.javaPath = path.join('Java_jdkfile_jdk', inputs.version, inputs.arch);
|
expected.javaPath = path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture);
|
||||||
await expect(mockJavaBase.setupJava()).rejects.toThrowError(
|
await expect(mockJavaBase.setupJava()).rejects.toThrowError(
|
||||||
"JDK file was not found in path 'not_existing_one'"
|
"JDK file was not found in path 'not_existing_one'"
|
||||||
);
|
);
|
||||||
|
@ -170,10 +170,10 @@ describe('setupJava', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[{ version: '8.0.289', arch: 'x64', packageType: 'jdk' }, 'otherJdkFile'],
|
[{ version: '8.0.289', architecture: 'x64', packageType: 'jdk' }, 'otherJdkFile'],
|
||||||
[{ version: '11.0.289', arch: 'x64', packageType: 'jdk' }, 'otherJdkFile'],
|
[{ version: '11.0.289', architecture: 'x64', packageType: 'jdk' }, 'otherJdkFile'],
|
||||||
[{ version: '12.0.289', arch: 'x64', packageType: 'jdk' }, 'otherJdkFile'],
|
[{ version: '12.0.289', architecture: 'x64', packageType: 'jdk' }, 'otherJdkFile'],
|
||||||
[{ version: '11.1.11', arch: 'x64', packageType: 'jdk' }, 'not_existing_one']
|
[{ version: '11.1.11', architecture: 'x64', packageType: 'jdk' }, 'not_existing_one']
|
||||||
])(
|
])(
|
||||||
`Throw an error if jdkfile has wrong path, inputs %s, jdkfile %s, real name ${expectedJdkFile}`,
|
`Throw an error if jdkfile has wrong path, inputs %s, jdkfile %s, real name ${expectedJdkFile}`,
|
||||||
async (inputs, jdkFile) => {
|
async (inputs, jdkFile) => {
|
||||||
|
@ -186,9 +186,9 @@ describe('setupJava', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[{ version: '8.0.289', arch: 'x64', packageType: 'jdk' }, ''],
|
[{ version: '8.0.289', architecture: 'x64', packageType: 'jdk' }, ''],
|
||||||
[{ version: '7.0.289', arch: 'x64', packageType: 'jdk' }, undefined],
|
[{ version: '7.0.289', architecture: 'x64', packageType: 'jdk' }, undefined],
|
||||||
[{ version: '11.0.289', arch: 'x64', packageType: 'jdk' }, undefined]
|
[{ version: '11.0.289', architecture: 'x64', packageType: 'jdk' }, undefined]
|
||||||
])('Throw an error if jdkfile is not specified, inputs %s', async (inputs, jdkFile) => {
|
])('Throw an error if jdkfile is not specified, inputs %s', async (inputs, jdkFile) => {
|
||||||
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
mockJavaBase = new LocalDistribution(inputs, jdkFile);
|
||||||
await expect(mockJavaBase.setupJava()).rejects.toThrowError("'jdkFile' is not specified");
|
await expect(mockJavaBase.setupJava()).rejects.toThrowError("'jdkFile' is not specified");
|
||||||
|
|
|
@ -30,27 +30,27 @@ describe('getAvailableVersions', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
{ version: '11', arch: 'x86', packageType: 'jdk' },
|
{ version: '11', architecture: 'x86', packageType: 'jdk' },
|
||||||
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga'
|
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '11-ea', arch: 'x86', packageType: 'jdk' },
|
{ version: '11-ea', architecture: 'x86', packageType: 'jdk' },
|
||||||
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea'
|
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '8', arch: 'x64', packageType: 'jdk' },
|
{ version: '8', architecture: 'x64', packageType: 'jdk' },
|
||||||
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
|
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '8', arch: 'x64', packageType: 'jre' },
|
{ version: '8', architecture: 'x64', packageType: 'jre' },
|
||||||
'?os=macos&ext=tar.gz&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
|
'?os=macos&ext=tar.gz&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '8', arch: 'x64', packageType: 'jdk+fx' },
|
{ version: '8', architecture: 'x64', packageType: 'jdk+fx' },
|
||||||
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
|
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '8', arch: 'x64', packageType: 'jre+fx' },
|
{ version: '8', architecture: 'x64', packageType: 'jre+fx' },
|
||||||
'?os=macos&ext=tar.gz&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
|
'?os=macos&ext=tar.gz&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
|
||||||
]
|
]
|
||||||
])('build correct url for %s -> %s', async (input, parsedUrl) => {
|
])('build correct url for %s -> %s', async (input, parsedUrl) => {
|
||||||
|
@ -65,7 +65,11 @@ describe('getAvailableVersions', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('load available versions', async () => {
|
it('load available versions', async () => {
|
||||||
const distribution = new ZuluDistribution({ version: '11', arch: 'x86', packageType: 'jdk' });
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk'
|
||||||
|
});
|
||||||
const availableVersions = await distribution['getAvailableVersions']();
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
expect(availableVersions).toHaveLength(manifestData.length);
|
expect(availableVersions).toHaveLength(manifestData.length);
|
||||||
});
|
});
|
||||||
|
@ -80,7 +84,7 @@ describe('getArchitectureOptions', () => {
|
||||||
])('%s -> %s', (input, expected) => {
|
])('%s -> %s', (input, expected) => {
|
||||||
const distribution = new ZuluDistribution({
|
const distribution = new ZuluDistribution({
|
||||||
version: '11',
|
version: '11',
|
||||||
arch: input.architecture,
|
architecture: input.architecture,
|
||||||
packageType: 'jdk'
|
packageType: 'jdk'
|
||||||
});
|
});
|
||||||
expect(distribution['getArchitectureOptions']()).toEqual(expected);
|
expect(distribution['getArchitectureOptions']()).toEqual(expected);
|
||||||
|
@ -103,7 +107,7 @@ describe('findPackageForDownload', () => {
|
||||||
])('version is %s -> %s', async (input, expected) => {
|
])('version is %s -> %s', async (input, expected) => {
|
||||||
const distribution = new ZuluDistribution({
|
const distribution = new ZuluDistribution({
|
||||||
version: input,
|
version: input,
|
||||||
arch: 'x86',
|
architecture: 'x86',
|
||||||
packageType: 'jdk'
|
packageType: 'jdk'
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
@ -112,7 +116,11 @@ describe('findPackageForDownload', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => {
|
it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => {
|
||||||
const distribution = new ZuluDistribution({ version: '', arch: 'x86', packageType: 'jdk' });
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk'
|
||||||
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
const result = await distribution['findPackageForDownload']('11.0.5');
|
const result = await distribution['findPackageForDownload']('11.0.5');
|
||||||
expect(result.url).toBe(
|
expect(result.url).toBe(
|
||||||
|
@ -121,7 +129,11 @@ describe('findPackageForDownload', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error', async () => {
|
it('should throw an error', async () => {
|
||||||
const distribution = new ZuluDistribution({ version: '18', arch: 'x86', packageType: 'jdk' });
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '18',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk'
|
||||||
|
});
|
||||||
await expect(
|
await expect(
|
||||||
distribution['findPackageForDownload'](distribution['version'])
|
distribution['findPackageForDownload'](distribution['version'])
|
||||||
).rejects.toThrowError(/Could not find satisfied version for semver */);
|
).rejects.toThrowError(/Could not find satisfied version for semver */);
|
||||||
|
@ -136,7 +148,11 @@ describe('convertVersionToSemver', () => {
|
||||||
[[12, 0, 2, 1], '12.0.2+1'],
|
[[12, 0, 2, 1], '12.0.2+1'],
|
||||||
[[12, 0, 2, 1, 3], '12.0.2+1']
|
[[12, 0, 2, 1, 3], '12.0.2+1']
|
||||||
])('%s -> %s', (input: number[], expected: string) => {
|
])('%s -> %s', (input: number[], expected: string) => {
|
||||||
const distribution = new ZuluDistribution({ version: '18', arch: 'x86', packageType: 'jdk' });
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '18',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk'
|
||||||
|
});
|
||||||
const actual = distribution['convertVersionToSemver'](input);
|
const actual = distribution['convertVersionToSemver'](input);
|
||||||
expect(actual).toBe(expected);
|
expect(actual).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue