test: Fix workDir cleanup

This commit is contained in:
peaceiris 2020-01-18 02:52:43 +00:00
parent 19019838e3
commit 9f27acbc58

View file

@ -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}`
);
});
});