Update tests to use 'jdk', 'jre', and 'jdk+fx' javaPackage parameters

This commit is contained in:
Gil Tene 2019-11-02 20:23:35 -07:00
parent 3c9738b031
commit 2275401b31

View file

@ -52,8 +52,8 @@ describe('installer tests', () => {
}, 100000);
it('Installs version of Java from jdkFile if no matching version is installed', async () => {
await installer.getJava('12', 'x64', javaFilePath);
const JavaDir = path.join(toolDir, 'Java', '12.0.0', 'x64');
await installer.getJava('12', 'x64', javaFilePath, 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '12.0.0', 'x64');
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
@ -62,7 +62,7 @@ describe('installer tests', () => {
it('Throws if invalid directory to jdk', async () => {
let thrown = false;
try {
await installer.getJava('1000', 'x64', 'bad path');
await installer.getJava('1000', 'x64', 'bad path', 'jdk');
} catch {
thrown = true;
}
@ -70,24 +70,42 @@ describe('installer tests', () => {
});
it('Downloads java if no file given', async () => {
await installer.getJava('8.0.102', 'x64', '');
const JavaDir = path.join(toolDir, 'Java', '8.0.102', 'x64');
await installer.getJava('8.0.102', 'x64', '', 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '8.0.102', 'x64');
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
}, 100000);
it('Downloads java with 1.x syntax', async () => {
await installer.getJava('1.10', 'x64', '');
const JavaDir = path.join(toolDir, 'Java', '10.0.2', 'x64');
await installer.getJava('1.10', 'x64', '', 'jdk');
// Relies on knowledge that the latest version of 10.0.x is 10.0.2, and it will likely not update again:
const JavaDir = path.join(toolDir, 'jdk', '10.0.2', 'x64');
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
}, 100000);
it('Downloads java with normal semver syntax', async () => {
await installer.getJava('9.0.x', 'x64', '');
const JavaDir = path.join(toolDir, 'Java', '9.0.7', 'x64');
await installer.getJava('9.0.x', 'x64', '', 'jdk');
// Relies on knowledge that the latest version of 9.0.x is 9.0.7, and it will likely not update again:
const JavaDir = path.join(toolDir, 'jdk', '9.0.7', 'x64');
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
}, 100000);
it('Downloads java if package is jre', async () => {
await installer.getJava('8.0.222', 'x64', '', 'jre');
const JavaDir = path.join(toolDir, 'jre', '8.0.222', 'x64');
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
}, 100000);
it('Downloads java if package is jdk+fx', async () => {
await installer.getJava('8.0.222', 'x64', '', 'jdk+fx');
const JavaDir = path.join(toolDir, 'jdk+fx', '8.0.222', 'x64');
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
@ -96,7 +114,7 @@ describe('installer tests', () => {
it('Throws if invalid directory to jdk', async () => {
let thrown = false;
try {
await installer.getJava('1000', 'x64', 'bad path');
await installer.getJava('1000', 'x64', 'bad path', 'jdk');
} catch {
thrown = true;
}
@ -104,25 +122,26 @@ describe('installer tests', () => {
});
it('Uses version of Java installed in cache', async () => {
const JavaDir: string = path.join(toolDir, 'Java', '250.0.0', 'x64');
const JavaDir: string = path.join(toolDir, 'jdk', '250.0.0', 'x64');
await io.mkdirP(JavaDir);
fs.writeFileSync(`${JavaDir}.complete`, 'hello');
// This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getJava(
'250',
'x64',
'path shouldnt matter, found in cache'
'path shouldnt matter, found in cache',
'jdk'
);
return;
});
it('Doesnt use version of Java that was only partially installed in cache', async () => {
const JavaDir: string = path.join(toolDir, 'Java', '251.0.0', 'x64');
const JavaDir: string = path.join(toolDir, 'jdk', '251.0.0', 'x64');
await io.mkdirP(JavaDir);
let thrown = false;
try {
// This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getJava('251', 'x64', 'bad path');
await installer.getJava('251', 'x64', 'bad path', 'jdk');
} catch {
thrown = true;
}