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

Function TestDo_httpError

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

Source from the content-addressed store, hash-verified

2189}
2190
2191func TestDo_httpError(t *testing.T) {
2192 t.Parallel()
2193 client, mux, _ := setup(t)
2194
2195 mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
2196 http.Error(w, "Bad Request", 400)
2197 })
2198
2199 req, _ := client.NewRequest(t.Context(), "GET", ".", nil)
2200 resp, err := client.Do(req, nil)
2201
2202 if err == nil {
2203 t.Fatal("Expected HTTP 400 error, got no error.")
2204 }
2205 if resp.StatusCode != 400 {
2206 t.Errorf("Expected HTTP 400 error, got %v status code.", resp.StatusCode)
2207 }
2208}
2209
2210// Test handling of an error caused by the internal http client's Do()
2211// function. A redirect loop is pretty unlikely to occur within the GitHub

Callers

nothing calls this directly

Calls 4

NewRequestMethod · 0.80
setupFunction · 0.70
ErrorMethod · 0.45
DoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…