MCPcopy Index your code
hub / github.com/google/go-github / TestDo

Function TestDo

github/github_test.go:2167–2189  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2165}
2166
2167func TestDo(t *testing.T) {
2168 t.Parallel()
2169 client, mux, _ := setup(t)
2170
2171 type foo struct {
2172 A string
2173 }
2174
2175 mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
2176 testMethod(t, r, "GET")
2177 fmt.Fprint(w, `{"A":"a"}`)
2178 })
2179
2180 req, _ := client.NewRequest(t.Context(), "GET", ".", nil)
2181 var body *foo
2182 _, err := client.Do(req, &body)
2183 assertNilError(t, err)
2184
2185 want := &foo{"a"}
2186 if !cmp.Equal(body, want) {
2187 t.Errorf("Response body = %v, want %v", body, want)
2188 }
2189}
2190
2191func TestDo_httpError(t *testing.T) {
2192 t.Parallel()

Callers

nothing calls this directly

Calls 6

testMethodFunction · 0.85
NewRequestMethod · 0.80
EqualMethod · 0.80
setupFunction · 0.70
assertNilErrorFunction · 0.70
DoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…