mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-24 02:37:29 +01:00
refactor: main and installer (#133)
* refactor: installer * test: Fix workDir cleanup
This commit is contained in:
@@ -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}`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user