test: Fix workDir cleanup
This commit is contained in:
parent
19019838e3
commit
9f27acbc58
1 changed files with 8 additions and 5 deletions
|
|
@ -2,12 +2,12 @@ import * as main from '../src/main';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import nock from 'nock';
|
import nock from 'nock';
|
||||||
|
import {Tool, Action} from '../src/constants';
|
||||||
// import {FetchError} from 'node-fetch';
|
// import {FetchError} from 'node-fetch';
|
||||||
import jsonTestBrew from './data/brew.json';
|
import jsonTestBrew from './data/brew.json';
|
||||||
// import jsonTestGithub from './data/github.json';
|
// import jsonTestGithub from './data/github.json';
|
||||||
|
|
||||||
jest.setTimeout(30000);
|
jest.setTimeout(30000);
|
||||||
const repo = 'hugo';
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
|
|
@ -20,11 +20,12 @@ afterEach(() => {
|
||||||
|
|
||||||
describe('Integration testing run()', () => {
|
describe('Integration testing run()', () => {
|
||||||
afterEach(async () => {
|
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 () => {
|
test('succeed in installing a custom version', async () => {
|
||||||
const testVersion = '0.61.0';
|
const testVersion = Tool.TestVersionSpec;
|
||||||
process.env['INPUT_HUGO-VERSION'] = testVersion;
|
process.env['INPUT_HUGO-VERSION'] = testVersion;
|
||||||
const result: main.ActionResult = await main.run();
|
const result: main.ActionResult = await main.run();
|
||||||
expect(result.exitcode).toBe(0);
|
expect(result.exitcode).toBe(0);
|
||||||
|
|
@ -35,11 +36,13 @@ describe('Integration testing run()', () => {
|
||||||
const testVersion = 'latest';
|
const testVersion = 'latest';
|
||||||
process.env['INPUT_HUGO-VERSION'] = testVersion;
|
process.env['INPUT_HUGO-VERSION'] = testVersion;
|
||||||
nock('https://formulae.brew.sh')
|
nock('https://formulae.brew.sh')
|
||||||
.get(`/api/formula/${repo}.json`)
|
.get(`/api/formula/${Tool.Repo}.json`)
|
||||||
.reply(200, jsonTestBrew);
|
.reply(200, jsonTestBrew);
|
||||||
const result: main.ActionResult = await main.run();
|
const result: main.ActionResult = await main.run();
|
||||||
expect(result.exitcode).toBe(0);
|
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}`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue