Skip to content

feat: Allow for mocking sdk.Client #355

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

Merged
merged 18 commits into from
Apr 5, 2024

Conversation

nieomylnieja
Copy link
Collaborator

@nieomylnieja nieomylnieja commented Apr 4, 2024

Motivation

Currently it's impossible to mock sdk.Client due to how versioned endpoints groups are returned, for example: sdk.Client.Objects returns a concrete struct: Versions which in turn holds methods for extracting specific API version's endpoints. There's no point mocking the sdk.Client.Objects method, it doesn't give us anything as it's just an intermediary on our way to access the specific endpoint function.

Summary

Changed the endpoints package to return interfaces rather than concrete structs so that they can be mocked.

Used https://github.com/vburenin/ifacemaker for the interfaces generation as it lifts up the maintenance cost of adding/modifying API methods.

@nieomylnieja nieomylnieja linked an issue Apr 4, 2024 that may be closed by this pull request
Copy link
Contributor

@daniel-zelazny daniel-zelazny left a comment

Choose a reason for hiding this comment

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

Good job - but we have some vulnerabilities reported.

nieomylnieja and others added 16 commits April 4, 2024 16:51
…obl9-go into allow-for-mocking-client-methods
@nieomylnieja nieomylnieja merged commit 0878756 into main Apr 5, 2024
5 checks passed
@nieomylnieja nieomylnieja deleted the allow-for-mocking-client-methods branch April 5, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mocking the noble9 sdk
3 participants