Skip to content

Instantly share code, notes, and snippets.

@markphelps
Last active September 24, 2017 15:46
Show Gist options
  • Save markphelps/365aa1d9fd2939115b3725d325445dfd to your computer and use it in GitHub Desktop.
Save markphelps/365aa1d9fd2939115b3725d325445dfd to your computer and use it in GitHub Desktop.
func fixture(path string) string {
b, err := ioutil.ReadFile("testdata/fixtures/" + path)
if err != nil {
panic(err)
}
return string(b)
}
func TestListRepos(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/orgs/octokit/repos", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, fixture("repos/octokit.json"))
})
repos, err := client.ListRepos("octokit")
if err := nil {
t.Fatal(err)
}
// ... other tests here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment