From f24de70161c371f770165c153b18689480f0809c Mon Sep 17 00:00:00 2001 From: beorn7 Date: Mon, 14 Oct 2019 19:24:20 +0200 Subject: [PATCH] Update push test to use status code 200 Signed-off-by: beorn7 --- prometheus/push/push_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/prometheus/push/push_test.go b/prometheus/push/push_test.go index 4992eb1..1fabe39 100644 --- a/prometheus/push/push_test.go +++ b/prometheus/push/push_test.go @@ -33,7 +33,8 @@ func TestPush(t *testing.T) { 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( http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { lastMethod = r.Method @@ -44,7 +45,11 @@ func TestPush(t *testing.T) { } lastPath = r.URL.EscapedPath() w.Header().Set("Content-Type", `text/plain; charset=utf-8`) - w.WriteHeader(http.StatusAccepted) + if r.Method == http.MethodDelete { + w.WriteHeader(http.StatusAccepted) + return + } + w.WriteHeader(http.StatusOK) }), ) defer pgwOK.Close()