Skip to content

github: turn `Client` into an interface

Warren Gifford requested to merge jc/make-github-client-interface into master

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:

  1. Turned github.Client into an interface, the previous client now became *client and implements the new github.Client interface.
  2. Created a *github.MockClient that also implements the new github.Client interface, but with fields could be used to inject with mock implementations in tests.
  3. Updated github_test.go to mock a client by assign values to the fields of MockClient. (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!

Merge request reports

Loading