refactor: Fix lint errors
This commit is contained in:
parent
86d998acdc
commit
ac375e4950
2 changed files with 22 additions and 26 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
import * as main from '../src/main';
|
import * as main from '../src/main';
|
||||||
const nock = require('nock');
|
import nock from 'nock';
|
||||||
// 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: string = 'hugo';
|
const repo = 'hugo';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
|
|
@ -18,7 +18,7 @@ afterEach(() => {
|
||||||
|
|
||||||
describe('Integration testing run()', () => {
|
describe('Integration testing run()', () => {
|
||||||
test('succeed in installing a custom version', async () => {
|
test('succeed in installing a custom version', async () => {
|
||||||
const testVersion: string = '0.61.0';
|
const testVersion = '0.61.0';
|
||||||
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);
|
||||||
|
|
@ -26,7 +26,7 @@ describe('Integration testing run()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('succeed in installing the latest version', async () => {
|
test('succeed in installing the latest version', async () => {
|
||||||
const testVersion: string = '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/${repo}.json`)
|
||||||
|
|
@ -49,11 +49,8 @@ describe('showVersion()', () => {
|
||||||
expect(result.output).toMatch(/git version/);
|
expect(result.output).toMatch(/git version/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('return exception', async () => {
|
test('return not found', async () => {
|
||||||
try {
|
|
||||||
result = await main.showVersion('gitgit', ['--version']);
|
result = await main.showVersion('gitgit', ['--version']);
|
||||||
} catch (e) {
|
expect(result.exitcode).not.toBe(0);
|
||||||
expect(e).toThrow(Error);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
11
src/main.ts
11
src/main.ts
|
|
@ -13,7 +13,6 @@ export async function showVersion(
|
||||||
cmd: string,
|
cmd: string,
|
||||||
args: string[]
|
args: string[]
|
||||||
): Promise<ActionResult> {
|
): Promise<ActionResult> {
|
||||||
try {
|
|
||||||
const result: ActionResult = {
|
const result: ActionResult = {
|
||||||
exitcode: 0,
|
exitcode: 0,
|
||||||
output: ''
|
output: ''
|
||||||
|
|
@ -27,15 +26,15 @@ export async function showVersion(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
result.exitcode = await exec.exec(cmd, args, options);
|
result.exitcode = await exec.exec(cmd, args, options);
|
||||||
core.debug(`
|
|
||||||
exit code: ${result.exitcode}
|
|
||||||
stdout: ${result.output}
|
|
||||||
`);
|
|
||||||
return result;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
core.debug(`command: ${cmd} ${args}`);
|
||||||
|
core.debug(`exit code: ${result.exitcode}`);
|
||||||
|
core.debug(`stdout: ${result.output}`);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function run(): Promise<ActionResult> {
|
export async function run(): Promise<ActionResult> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue