chore(tests): add more asserts in metrics tests

This commit is contained in:
Łukasz Mierzwa
2019-05-12 11:53:39 +01:00
parent 65e7ddf36c
commit fbdd171a85
+12
View File
@@ -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)
}
}
}