This commit is contained in:
Shohei Ueda 2024-06-19 18:58:17 +09:00 committed by GitHub
commit f32618c774
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -25,6 +25,7 @@ describe('Integration testing run()', () => {
test('succeed in installing a custom version', async () => { test('succeed in installing a custom version', async () => {
const testVersion = Tool.TestVersionSpec; const testVersion = Tool.TestVersionSpec;
process.env['INPUT_HUGO-VERSION'] = testVersion; process.env['INPUT_HUGO-VERSION'] = testVersion;
process.env['INPUT_EXTENDED'] = 'false';
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 v${testVersion}`); expect(result.output).toMatch(`hugo v${testVersion}`);
@ -43,6 +44,7 @@ describe('Integration testing run()', () => {
test('succeed in installing the latest version', async () => { test('succeed in installing the latest version', async () => {
const testVersion = 'latest'; const testVersion = 'latest';
process.env['INPUT_HUGO-VERSION'] = testVersion; process.env['INPUT_HUGO-VERSION'] = testVersion;
process.env['INPUT_EXTENDED'] = 'false';
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew); nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).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);
@ -62,8 +64,8 @@ describe('Integration testing run()', () => {
test('fail to install the latest version due to 404 of brew', async () => { test('fail to install the latest version due to 404 of brew', async () => {
process.env['INPUT_HUGO-VERSION'] = 'latest'; process.env['INPUT_HUGO-VERSION'] = 'latest';
process.env['INPUT_EXTENDED'] = 'false';
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404); nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404);
await expect(main.run()).rejects.toThrowError(FetchError); await expect(main.run()).rejects.toThrowError(FetchError);
}); });
}); });

View File

@ -7,10 +7,10 @@ export default function getURL(
const extendedStr = (extended: string): string => { const extendedStr = (extended: string): string => {
if (extended === 'true') { if (extended === 'true') {
return 'extended_'; return 'extended_';
} else { } else if (extended === 'false') {
return ''; return '';
// } else { } else {
// throw new Error(`Invalid input (extended): ${extended}`); throw new Error(`Invalid input (extended): ${extended}`);
} }
}; };