|
|
|
@ -151,6 +151,28 @@ func TestDo_httpError(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Test handling of an error caused by the internal http client's Do()
|
|
|
|
// function. A redirect loop is pretty unlikely to occur within the GitHub
|
|
|
|
// API, but does allow us to exercise the right code path.
|
|
|
|
func TestDo_redirectLoop(t *testing.T) { |
|
|
|
setup() |
|
|
|
defer teardown() |
|
|
|
|
|
|
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
|
|
|
http.Redirect(w, r, "/", http.StatusFound) |
|
|
|
}) |
|
|
|
|
|
|
|
req, _ := client.NewRequest("GET", "/", nil) |
|
|
|
_, err := client.Do(req, nil) |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
t.Error("Expected error to be returned.") |
|
|
|
} |
|
|
|
if err, ok := err.(*url.Error); !ok { |
|
|
|
t.Errorf("Expected a URL error; got %#v.", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func TestCheckResponse(t *testing.T) { |
|
|
|
res := &http.Response{ |
|
|
|
Request: &http.Request{}, |
|
|
|
|