Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: throw error for invalid extended input #387

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Integration testing run()', () => {
test('succeed in installing a custom version', async () => {
const testVersion = Tool.TestVersionSpec;
process.env['INPUT_HUGO-VERSION'] = testVersion;
process.env['INPUT_EXTENDED'] = 'false';
const result: main.ActionResult = await main.run();
expect(result.exitcode).toBe(0);
expect(result.output).toMatch(`Hugo Static Site Generator v${testVersion}`);
Expand All @@ -43,6 +44,7 @@ describe('Integration testing run()', () => {
test('succeed in installing the latest version', async () => {
const testVersion = 'latest';
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);
const result: main.ActionResult = await main.run();
expect(result.exitcode).toBe(0);
Expand All @@ -62,8 +64,8 @@ describe('Integration testing run()', () => {

test('fail to install the latest version due to 404 of brew', async () => {
process.env['INPUT_HUGO-VERSION'] = 'latest';
process.env['INPUT_EXTENDED'] = 'false';
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404);

await expect(main.run()).rejects.toThrowError(FetchError);
});
});
Expand Down
6 changes: 3 additions & 3 deletions src/get-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ export default function getURL(os: string, extended: string, version: string): s
const extendedStr = (extended: string): string => {
if (extended === 'true') {
return 'extended_';
} else {
} else if (extended === 'false') {
return '';
// } else {
// throw new Error(`Invalid input (extended): ${extended}`);
} else {
throw new Error(`Invalid input (extended): ${extended}`);
}
};

Expand Down