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(exp): add hcloud client mock package #442

Closed
wants to merge 6 commits into from
Closed

feat(exp): add hcloud client mock package #442

wants to merge 6 commits into from

Conversation

jooola
Copy link
Member

@jooola jooola commented May 13, 2024

This adds a generated mock for the hcloudmock.Client that will be usable for external library for testing.

@jooola jooola requested a review from a team as a code owner May 13, 2024 13:14
Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 70.54%. Comparing base (a61c494) to head (0f02426).

Files Patch % Lines
hcloud/exp/hcloudmock/client.go 0.00% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #442      +/-   ##
==========================================
- Coverage   70.91%   70.54%   -0.38%     
==========================================
  Files          35       36       +1     
  Lines        3772     3792      +20     
==========================================
  Hits         2675     2675              
- Misses        688      708      +20     
  Partials      409      409              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@phm07
Copy link
Contributor

phm07 commented May 21, 2024

I started implementing the new mocks in the CLI: hetznercloud/cli@4329583
It saves us quite a bit of code there. Although it would be nicer if we had a unified interface that the mock client would implement and also a wrapper for the regular hcloud-go client that has those methods, like we do in the hcapi2 package in the cli.
On a side note, I think the package name mock is a bit too generic and could cause some collisions. I still think it's a very good idea to put this logic into hcloud-go instead of cluttering other integrations with it.

hcloud/exp/mock/client.go Outdated Show resolved Hide resolved
@jooola jooola requested a review from phm07 May 24, 2024 11:19
@jooola
Copy link
Member Author

jooola commented May 24, 2024

Although it would be nicer if we had a unified interface that the mock client would implement and also a wrapper for the regular hcloud-go client that has those methods, like we do in the hcapi2 package in the cli.

I am not sure to fully understand your suggestions, could you elaborate please?

@jooola jooola requested a review from apricote May 28, 2024 12:30
@jooola jooola marked this pull request as draft May 29, 2024 17:40
@jooola
Copy link
Member Author

jooola commented May 29, 2024

Implementing a mock for the client will be on hold until we can implement an interface first client. The current struct based client does not allow us to swap the client implementation (real and mock) easily.

@jooola jooola closed this May 29, 2024
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