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

chore: Add mockable http client to simple client #209

Merged
merged 3 commits into from
Dec 5, 2024

Conversation

epociask
Copy link
Collaborator

@epociask epociask commented Dec 4, 2024

Fixes Issue

Fixes #

Changes proposed

Screenshots (Optional)

Note to reviewers

@epociask epociask requested a review from samlaf December 4, 2024 14:14
client/simple.go Outdated Show resolved Hide resolved
Comment on lines +20 to +21
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this really needed here? How are you mocking the client? with some mock library?
Can we use https://pkg.go.dev/net/http/httptest#Server.Client instead to simplify the code and not have this interface (don't think its typical to have an interface for an http client in golang, but not 100% sure)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its easiest for me to just bind it to an interface for mocking - done this across quite a few projects in the past

client/simple.go Outdated Show resolved Hide resolved
client/simple.go Outdated Show resolved Hide resolved
@epociask epociask requested a review from samlaf December 4, 2024 14:34
@epociask epociask merged commit 2fd70b9 into main Dec 5, 2024
7 checks passed
@epociask epociask deleted the epociask--chore-mockable-http-for-simple-clint branch December 5, 2024 11:58
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