resolve comment for check-latest

This commit is contained in:
Dmitry Shibanov 2021-03-22 12:14:18 +03:00
parent 61c3e48d26
commit 6e6487b787
7 changed files with 105 additions and 52 deletions

View file

@ -58,15 +58,15 @@ describe('findInToolcache', () => {
it.each([
[
{ version: '11', architecture: 'x64', packageType: 'jdk' },
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{ version: actualJavaVersion, path: javaPath }
],
[
{ version: '11.0', architecture: 'x64', packageType: 'jdk' },
{ version: '11.0', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{ version: actualJavaVersion, path: javaPath }
],
[
{ version: '11.0.8', architecture: 'x64', packageType: 'jdk' },
{ version: '11.0.8', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{ version: actualJavaVersion, path: javaPath }
],
[
@ -81,10 +81,10 @@ describe('findInToolcache', () => {
{ version: '11.0.8', architecture: 'x64', packageType: 'jdk', checkLatest: true },
{ version: actualJavaVersion, path: javaPath }
],
[{ version: '11', architecture: 'x64', packageType: 'jre' }, null],
[{ version: '8', architecture: 'x64', packageType: 'jdk' }, null],
[{ version: '11', architecture: 'x86', packageType: 'jdk' }, null],
[{ version: '11', architecture: 'x86', packageType: 'jre' }, null]
[{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false }, null],
[{ version: '8', architecture: 'x64', packageType: 'jdk', checkLatest: false }, null],
[{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false }, null],
[{ version: '11', architecture: 'x86', packageType: 'jre', checkLatest: false }, null]
])(`should find java for path %s -> %s`, (input, expected) => {
spyTcFindAllVersions.mockReturnValue([actualJavaVersion]);
spyGetToolcachePath.mockImplementation(
@ -127,7 +127,12 @@ describe('findInToolcache', () => {
(toolname: string, javaVersion: string, architecture: string) =>
`/hostedtoolcache/${toolname}/${javaVersion}/${architecture}`
);
mockJavaBase = new EmptyJavaBase({ version: input, architecture: 'x64', packageType: 'jdk' });
mockJavaBase = new EmptyJavaBase({
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const foundVersion = mockJavaBase['findInToolcache']();
expect(foundVersion?.version).toEqual(expected);
});
@ -191,15 +196,15 @@ describe('setupJava', () => {
it.each([
[
{ version: '11', architecture: 'x86', packageType: 'jdk' },
{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{ version: installedJavaVersion, path: javaPath }
],
[
{ version: '11.0', architecture: 'x86', packageType: 'jdk' },
{ version: '11.0', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{ version: installedJavaVersion, path: javaPath }
],
[
{ version: '11.0.8', architecture: 'x86', packageType: 'jdk' },
{ version: '11.0.8', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{ version: installedJavaVersion, path: javaPath }
]
])('should find java locally for %s', (input, expected) => {
@ -216,15 +221,15 @@ describe('setupJava', () => {
it.each([
[
{ version: '11', architecture: 'x86', packageType: 'jre' },
{ version: '11', architecture: 'x86', packageType: 'jre', checkLatest: false },
{ path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'), version: '11.0.9' }
],
[
{ version: '11', architecture: 'x64', packageType: 'jdk' },
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{ path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64'), version: '11.0.9' }
],
[
{ version: '11', architecture: 'x64', packageType: 'jre' },
{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false },
{ path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x64'), version: '11.0.9' }
]
])('download java with configuration %s', async (input, expected) => {
@ -281,8 +286,8 @@ describe('setupJava', () => {
});
it.each([
[{ version: '15', architecture: 'x86', packageType: 'jre' }],
[{ version: '11.0.7', architecture: 'x64', packageType: 'jre' }]
[{ version: '15', architecture: 'x86', packageType: 'jre', checkLatest: false }],
[{ version: '11.0.7', architecture: 'x64', packageType: 'jre', checkLatest: false }]
])('should throw an error for Available version not found for %s', async input => {
mockJavaBase = new EmptyJavaBase(input);
await expect(mockJavaBase.setupJava()).rejects.toThrowError('Available version not found');