I am writing a program that acts as a client of Github API. I use http://ift.tt/14QceB2 to access the API. I have a function that accepts a github.Client
as one of the argumenta and uses it to retrieve commits from a pull request. I want to test this function with some fake data.
In the article here: http://ift.tt/2douGqG I read, that I should create an interface that would be implemented by github client, and then in my tests, create a mock that would also implement it. My problem is, that go-github
uses the following semantics to retrieve pull request:
prs, resp, err := client.PullRequests.List("user", "repo", opt)
The interfaces however allow you to specify methods that should be implemented, but not fields. So how can I mock the github.Client object so it can be used in the above semantics?
Aucun commentaire:
Enregistrer un commentaire