Merge pull request #11951 from Fish-pro/chore/httpvar

Use http constants instead of string
This commit is contained in:
Julien Pivotto 2023-02-10 22:44:50 +01:00 committed by GitHub
commit dfd2b5340e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 6 deletions

View file

@ -365,7 +365,7 @@ func TestGetDatacenterShouldReturnError(t *testing.T) {
{
// Define a handler that will return status 500.
handler: func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(500)
w.WriteHeader(http.StatusInternalServerError)
},
errMessage: "Unexpected response code: 500 ()",
},

View file

@ -74,16 +74,16 @@ func createTestHTTPServer(t *testing.T, responder discoveryResponder) *httptest.
discoveryRes, err := responder(discoveryReq)
if err != nil {
w.WriteHeader(500)
w.WriteHeader(http.StatusInternalServerError)
return
}
if discoveryRes == nil {
w.WriteHeader(304)
w.WriteHeader(http.StatusNotModified)
return
}
w.WriteHeader(200)
w.WriteHeader(http.StatusOK)
data, err := protoJSONMarshalOptions.Marshal(discoveryRes)
require.NoError(t, err)

View file

@ -87,7 +87,7 @@ func TestStoreHTTPErrorHandling(t *testing.T) {
func TestClientRetryAfter(t *testing.T) {
server := httptest.NewServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, longErrMessage, 429)
http.Error(w, longErrMessage, http.StatusTooManyRequests)
}),
)
defer server.Close()

View file

@ -2783,7 +2783,7 @@ func TestRespondSuccess(t *testing.T) {
t.Fatalf("Error reading response body: %s", err)
}
if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
t.Fatalf("Return code %d expected in success response but got %d", 200, resp.StatusCode)
}
if h := resp.Header.Get("Content-Type"); h != "application/json" {