Clean tests

This commit is contained in:
Danny McCormick 2019-06-07 17:08:50 -04:00
parent 6b9204b3ed
commit 1bb67f3744

View File

@ -3,8 +3,8 @@ import fs = require('fs');
import os = require('os'); import os = require('os');
import path = require('path'); import path = require('path');
const toolDir = path.join(__dirname, 'runner', 'tools'); const toolDir = path.join(process.cwd(), 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp'); const tempDir = path.join(process.cwd(), 'runner', 'temp');
process.env['RUNNER_TOOLSDIRECTORY'] = toolDir; process.env['RUNNER_TOOLSDIRECTORY'] = toolDir;
process.env['RUNNER_TEMPDIRECTORY'] = tempDir; process.env['RUNNER_TEMPDIRECTORY'] = tempDir;
@ -13,11 +13,10 @@ import * as installer from '../src/installer';
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
describe('installer tests', () => { describe('installer tests', () => {
beforeAll(() => {});
beforeAll(async () => { beforeAll(async () => {
await io.rmRF(toolDir); await io.rmRF(toolDir);
await io.rmRF(tempDir); await io.rmRF(tempDir);
}); }, 100000);
it('Acquires version of node if no matching version is installed', async () => { it('Acquires version of node if no matching version is installed', async () => {
await installer.getNode('10.16.0'); await installer.getNode('10.16.0');
@ -81,7 +80,7 @@ describe('installer tests', () => {
}); });
it('Doesnt use version of node that was only partially installed in cache', async () => { it('Doesnt use version of node that was only partially installed in cache', async () => {
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch()); const nodeDir: string = path.join(toolDir, 'node', '251.0.0', os.arch());
await io.mkdirP(nodeDir); await io.mkdirP(nodeDir);
let thrown = false; let thrown = false;
try { try {
@ -95,12 +94,12 @@ describe('installer tests', () => {
}); });
it('Resolves semantic versions of node installed in cache', async () => { it('Resolves semantic versions of node installed in cache', async () => {
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch()); const nodeDir: string = path.join(toolDir, 'node', '252.0.0', os.arch());
await io.mkdirP(nodeDir); await io.mkdirP(nodeDir);
fs.writeFileSync(`${nodeDir}.complete`, 'hello'); fs.writeFileSync(`${nodeDir}.complete`, 'hello');
// These will throw if it doesn't find it in the cache (because no such version exists) // These will throw if it doesn't find it in the cache (because no such version exists)
await installer.getNode('250.0.0'); await installer.getNode('252.0.0');
await installer.getNode('250'); await installer.getNode('252');
await installer.getNode('250.0'); await installer.getNode('252.0');
}); });
}); });