Last active
September 24, 2017 15:46
-
-
Save markphelps/365aa1d9fd2939115b3725d325445dfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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