From 9f27acbc58ff6c7493a1771d2ddd32c893612e1c Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sat, 18 Jan 2020 02:52:43 +0000 Subject: [PATCH] test: Fix workDir cleanup --- __tests__/main.test.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 311d564..7b95c7a 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -2,12 +2,12 @@ import * as main from '../src/main'; import * as io from '@actions/io'; import path from 'path'; import nock from 'nock'; +import {Tool, Action} from '../src/constants'; // import {FetchError} from 'node-fetch'; import jsonTestBrew from './data/brew.json'; // import jsonTestGithub from './data/github.json'; jest.setTimeout(30000); -const repo = 'hugo'; beforeEach(() => { jest.resetModules(); @@ -20,11 +20,12 @@ afterEach(() => { describe('Integration testing run()', () => { afterEach(async () => { - await io.rmRF(path.join(`${process.env.HOME}`, 'tmp')); + const workDir = path.join(`${process.env.HOME}`, Action.WorkDirName); + await io.rmRF(workDir); }); test('succeed in installing a custom version', async () => { - const testVersion = '0.61.0'; + const testVersion = Tool.TestVersionSpec; process.env['INPUT_HUGO-VERSION'] = testVersion; const result: main.ActionResult = await main.run(); expect(result.exitcode).toBe(0); @@ -35,11 +36,13 @@ describe('Integration testing run()', () => { const testVersion = 'latest'; process.env['INPUT_HUGO-VERSION'] = testVersion; nock('https://formulae.brew.sh') - .get(`/api/formula/${repo}.json`) + .get(`/api/formula/${Tool.Repo}.json`) .reply(200, jsonTestBrew); const result: main.ActionResult = await main.run(); expect(result.exitcode).toBe(0); - expect(result.output).toMatch('Hugo Static Site Generator v0.62.2'); + expect(result.output).toMatch( + `Hugo Static Site Generator v${Tool.TestVersionLatest}` + ); }); });