Skip to content

Commit

Permalink
Merge pull request #11951 from Fish-pro/chore/httpvar
Browse files Browse the repository at this point in the history
Use http constants instead of string
  • Loading branch information
roidelapluie committed Feb 10, 2023
2 parents af1d9e0 + 43d77f7 commit dfd2b53
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion discovery/consul/consul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()",
},
Expand Down
6 changes: 3 additions & 3 deletions discovery/xds/xds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion storage/remote/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion web/api/v1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit dfd2b53

Please sign in to comment.