github: turn `Client` into an interface
Created by: unknwon
Think this PR more like a proposal of "how to avoid global state mocks", this is a concrete example for GitHub API client.
Things happens:
- Turned
github.Client
into an interface, the previous client now became*client
and implements the newgithub.Client
interface. - Created a
*github.MockClient
that also implements the newgithub.Client
interface, but with fields could be used to inject with mock implementations in tests. - Updated
github_test.go
to mock a client by assign values to the fields ofMockClient
. (could have updated other places, but not in this PR)
NOTE:
- No functional change should happen in this PR.
- Other than the big
github.Client
interface, I'm pretty happy with this approach.
Any feedback is welcome!