Use http constants instead of string

Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
pull/11951/head
Fish-pro 2 years ago
parent c70d85baed
commit 43d77f7c41

@ -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 ()",
},

@ -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)

@ -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()

@ -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" {

Loading…
Cancel
Save