From 1bca1dc5d1e0cb195502e669ff834b9a7e37151b Mon Sep 17 00:00:00 2001 From: Zachary Eisinger Date: Thu, 19 Dec 2019 14:44:08 -0800 Subject: [PATCH] Test run proper check for accurate installation --- __tests__/authutil.test.ts | 4 ++++ __tests__/installer.test.ts | 11 ++++------- __tests__/setup-dotnet.test.ts | 10 ++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/__tests__/authutil.test.ts b/__tests__/authutil.test.ts index 1e12e02..cdffe3f 100644 --- a/__tests__/authutil.test.ts +++ b/__tests__/authutil.test.ts @@ -84,6 +84,10 @@ describe('authutil tests', () => { await io.mkdirP(fakeSourcesDirForTesting); }, 30000); + afterAll(async () => { + await io.rmRF(fakeSourcesDirForTesting); + }, 30000); + beforeEach(() => { if (fs.existsSync(nugetConfigFile)) { fs.unlinkSync(nugetConfigFile); diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 30a76f3..f010056 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -1,6 +1,5 @@ import io = require('@actions/io'); import fs = require('fs'); -import os = require('os'); import path = require('path'); import httpClient = require('typed-rest-client/HttpClient'); @@ -31,15 +30,13 @@ describe('installer tests', () => { it('Acquires version of dotnet if no matching version is installed', async () => { await getDotnet('3.1.100'); - const dotnetDir = path.join(toolDir, 'dncs', '3.1.100', os.arch()); - - expect(fs.existsSync(`${dotnetDir}.complete`)).toBe(true); + expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.100'))).toBe(true); if (IS_WINDOWS) { - expect(fs.existsSync(path.join(dotnetDir, 'dotnet.exe'))).toBe(true); + expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true); } else { - expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true); + expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); } - }, 30000); + }, 100000); it('Throws if no location contains correct dotnet version', async () => { let thrown = false; diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index 8c120e6..398ae14 100644 --- a/__tests__/setup-dotnet.test.ts +++ b/__tests__/setup-dotnet.test.ts @@ -30,8 +30,6 @@ describe('setup-dotnet tests', () => { }, 30000); it('Acquires version of dotnet if no matching version is installed', async () => { - const dotnetDir = path.join(toolDir, 'dncs', '3.1.100', os.arch()); - const globalJsonPath = path.join(process.cwd(), 'global.json'); const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "3.1.100"${os.EOL}}${os.EOL}}`; if (!fs.existsSync(globalJsonPath)) { @@ -39,12 +37,12 @@ describe('setup-dotnet tests', () => { } await setup.run(); - expect(fs.existsSync(`${dotnetDir}.complete`)).toBe(true); + expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.100'))).toBe(true); if (IS_WINDOWS) { - expect(fs.existsSync(path.join(dotnetDir, 'dotnet.exe'))).toBe(true); + expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true); } else { - expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true); + expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); } fs.unlinkSync(globalJsonPath); - }, 30000); + }, 100000); });