-
Notifications
You must be signed in to change notification settings - Fork 55
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
Setup mocks #35
Setup mocks #35
Conversation
package main | ||
|
||
import ( | ||
_ "github.com/golang/mock/mockgen" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is important so we can vendor our tooling deps.
ResourceServer ResourceServerAPI | ||
} | ||
|
||
func NewAPI(m *management.Management) *API { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not pass the token details instead and make the client directly here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's basically because the management constructor having a plethora of options and encoding that vs catching a fully formed struct being easier
I like it 👍🏻 I wonder though if we should specify more minimal interfaces, only the methods we're actually using to keep the verbosity down. On the other hand, if the goal is to just get something working such that we can later push the interfaces (and maybe even the mocks) upstream then great, that works too. |
Yes the intention is for us to upstream this, or basically push the envelope in terms of the current sdk's limitations |
Description
In order to provide easier testability, we're going to utilize https://github.com/golang/mock. For us to utilize that, we'll want to have clear interfaces we can mock.
Unfortunately, the go sdk today doesn't have that, so we're going to shim interfaces / functions which would allow us to mock cleanly.
Changes
golang/mock/mockgen
to generate mock files.golang/mock/go-mock
to work with mocks during the client test.internal/auth0
package to create a point of mocking.internal/auth0.API
struct to hold our interface style management client.