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: create new Metabase client #3970

Merged
merged 18 commits into from
Dec 2, 2024
Merged

feat: create new Metabase client #3970

merged 18 commits into from
Dec 2, 2024

Conversation

zz-hh-aa
Copy link
Collaborator

What does this PR do?

  • Creates Metabase client
    • Checks Metabase connection
    • Axios makes request to Metabase, and validates environment variables in createMetabaseClient
    • Sets up custom MetabaseError class
    • Retries for 5xx errors
  • Creates an input type for the Metabase client
    • Creates validateInput() function to check that client input is the expected shape & data types

Copy link

github-actions bot commented Nov 18, 2024

Removed vultr server and associated DNS entries

Base automatically changed from oz/restructure-analytics to main November 18, 2024 12:00
@zz-hh-aa zz-hh-aa force-pushed the oz/metabase-client-setup branch from 9685a81 to 6264cc2 Compare November 18, 2024 12:02
@zz-hh-aa zz-hh-aa requested a review from a team November 18, 2024 12:16
Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

A few minor comments and suggestions here and there 👍

I think we should also test this client with unit tests in isolation - a lot of the functionality here could be hit using axios mocks for responses and requests. If you search vi.mocked(axios, true) in the codebase you'll find some existing examples.

@zz-hh-aa
Copy link
Collaborator Author

zz-hh-aa commented Nov 20, 2024

Thanks for the detailed review @DafyddLlyr 🌟 I believe I have addressed most of your comments but I have one more outstanding question:

I think we should also test this client with unit tests in isolation - a lot of the functionality here could be hit using axios mocks for responses and requests. If you search vi.mocked(axios, true) in the codebase you'll find some existing examples.

Do you think those unit tests should be added to client.test.ts as part of this PR?

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes look great thanks, marked all as resolved 👍

Do you think those unit tests should be added to client.test.ts as part of this PR?

I think it's worth doing it in this PR - this way we have an addition to the code base associated with all its requisite tests which is a nice way of working.

By purely testing the client itself (e.g. how it behaves without secrets, the retry logic, passing of API key, error handling) we'll end up with client-specific functionality covered here, and then the Metabase-specific functionality can be tested a little more cleanly also.

@zz-hh-aa zz-hh-aa force-pushed the oz/metabase-client-setup branch from 7323e37 to b3947be Compare November 26, 2024 09:54
Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Two small comments and then I think we're good to go here 👌

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! ✅

Comment on lines 23 to 28
expect(client.defaults.baseURL).toBe(process.env.METABASE_URL_EXT);
expect(client.defaults.headers["X-API-Key"]).toBe(
process.env.METABASE_API_KEY,
);
expect(client.defaults.headers["Content-Type"]).toBe("application/json");
expect(client.defaults.timeout).toBe(30_000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@zz-hh-aa zz-hh-aa merged commit d4bbe91 into main Dec 2, 2024
12 checks passed
@zz-hh-aa zz-hh-aa deleted the oz/metabase-client-setup branch December 2, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants