test: Add fail to fetch latest due to 404 (#137)
This commit is contained in:
parent
0311892edd
commit
b55f1c81fb
2 changed files with 18 additions and 11 deletions
|
@ -3,25 +3,23 @@ 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 {FetchError} from 'node-fetch';
|
||||
import jsonTestBrew from './data/brew.json';
|
||||
// import jsonTestGithub from './data/github.json';
|
||||
|
||||
jest.setTimeout(30000);
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete process.env['INPUT_HUGO-VERSION'];
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe('Integration testing run()', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
const workDir = path.join(`${process.env.HOME}`, Action.WorkDirName);
|
||||
await io.rmRF(workDir);
|
||||
|
||||
delete process.env['INPUT_HUGO-VERSION'];
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
test('succeed in installing a custom version', async () => {
|
||||
|
@ -69,6 +67,15 @@ describe('Integration testing run()', () => {
|
|||
);
|
||||
expect(result.output).toMatch(`extended`);
|
||||
});
|
||||
|
||||
test('fail to install the latest version due to 404 of brew', async () => {
|
||||
process.env['INPUT_HUGO-VERSION'] = 'latest';
|
||||
nock('https://formulae.brew.sh')
|
||||
.get(`/api/formula/${Tool.Repo}.json`)
|
||||
.reply(404);
|
||||
|
||||
await expect(main.run()).rejects.toThrowError(FetchError);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showVersion()', () => {
|
||||
|
|
|
@ -56,6 +56,6 @@ export async function run(): Promise<ActionResult> {
|
|||
return result;
|
||||
} catch (e) {
|
||||
core.setFailed(`Action failed with error ${e}`);
|
||||
return e;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue