From fbdd171a85e22fd0215375909832c3cee8dc7f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Sun, 12 May 2019 11:53:39 +0100 Subject: [PATCH] chore(tests): add more asserts in metrics tests --- main_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main_test.go b/main_test.go index dafd23e21..d4a7e4266 100644 --- a/main_test.go +++ b/main_test.go @@ -3,6 +3,7 @@ package main import ( "net/http" "net/http/httptest" + "strings" "testing" "github.com/prymitive/karma/internal/config" @@ -39,4 +40,15 @@ func TestMetrics(t *testing.T) { if resp.Code != http.StatusOK { t.Errorf("GET /metrics returned status %d", resp.Code) } + body := resp.Body.String() + for _, s := range []string{ + "karma_collected_alerts_count", + "karma_collected_alerts_count", + "karma_collect_cycles_total", + "karma_alertmanager_errors_total", + } { + if !strings.Contains(body, s) { + t.Errorf("Metric '%s' missing from /metrics response", s) + } + } }