Update push test to use status code 200

Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
beorn7 2019-10-14 19:24:20 +02:00
parent 3ddc3cfbe5
commit f24de70161
1 changed files with 7 additions and 2 deletions

View File

@ -33,7 +33,8 @@ func TestPush(t *testing.T) {
lastPath string lastPath string
) )
// Fake a Pushgateway that always responds with 202. // Fake a Pushgateway that responds with 202 to DELETE and with 200 in
// all other cases.
pgwOK := httptest.NewServer( pgwOK := httptest.NewServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
lastMethod = r.Method lastMethod = r.Method
@ -44,7 +45,11 @@ func TestPush(t *testing.T) {
} }
lastPath = r.URL.EscapedPath() lastPath = r.URL.EscapedPath()
w.Header().Set("Content-Type", `text/plain; charset=utf-8`) w.Header().Set("Content-Type", `text/plain; charset=utf-8`)
if r.Method == http.MethodDelete {
w.WriteHeader(http.StatusAccepted) w.WriteHeader(http.StatusAccepted)
return
}
w.WriteHeader(http.StatusOK)
}), }),
) )
defer pgwOK.Close() defer pgwOK.Close()