mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Merge pull request #11951 from Fish-pro/chore/httpvar
Use http constants instead of string
This commit is contained in:
commit
dfd2b5340e
|
@ -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…
Reference in a new issue