-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fake Client (feature request) #2024
Comments
Thank you, @RafaeLeal - this sounds cool! Before we proceed any further, could you please take a moment and read through #1800 since I think that is relevant. We might recommend creating your |
Thanks for the link, I read some of the discussion.. In my case, I don't need to embed interfaces into the struct, but I'd benefit from having interfaces for the client. type githubClient struct {
client *github.Client
}
func New() (Interface, error) {
gh, err := client.NewGithubClient()
if err != nil {
return nil, err
}
return &githubClient{client: gh}, nil
}
func (g *githubClient) ChecksService() ChecksServiceInterface {
return g.client.Checks
}
func (g *githubClient) RepositoriesService() RepositoriesServiceInterface {
return g.client.Repositories
}
func (g *githubClient) IssuesService() IssuesServiceInterface {
return g.client.Issues
} and this type of code seems a bad smell since it's going to require us to keep with the changes inside this repo. I can't simply use githubClient := github.NewClient(nil) // returns *github.Client
githubClient.Checks.CreateCheckRun(...) because we need the interfaces to fake them |
Hi @RafaeLeal , after lots of conversations and feedback about this topic from the folks from Have a look: https://github.com/google/go-github#testing-code-that-uses-go-github |
Closing feature request. Please let us know (or submit a PR that updates README.md) if you decide to create another external helper repo that we can point to, @RafaeLeal . |
Hi!
My team has been using this client a lot to integrate our new CICD tool (Tekton) with Github. Thanks, btw! It mostly "just works" :)
To test these integrations, we implemented a simple fake client. I'd like to ask if a PR adding a fake client would be welcome.
This would require us to add interfaces for the client and its services..
Just a quick view of how that would look like:
Then you could use the client though the interfaces:
And it would be the same for fake client
The text was updated successfully, but these errors were encountered: