From ae94210a898ac1d5f64aae5c0b693ba61a9b2558 Mon Sep 17 00:00:00 2001 From: Damien Grisonnet Date: Thu, 10 Oct 2024 21:16:18 +0200 Subject: [PATCH] testutil: add compare test with absent metric Signed-off-by: Damien Grisonnet --- prometheus/testutil/testutil_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/prometheus/testutil/testutil_test.go b/prometheus/testutil/testutil_test.go index ec835a6..ce0f8ca 100644 --- a/prometheus/testutil/testutil_test.go +++ b/prometheus/testutil/testutil_test.go @@ -396,6 +396,18 @@ func TestScrapeAndCompare(t *testing.T) { metricNames: []string{"some_total1", "some_total3"}, expectedErr: "expected metric name(s) not found: [some_total1 some_total3]", }, + "metric registered but absent": { + want: ` + # HELP some_total A value that represents a counter. + # TYPE some_total counter + + some_total{ label1 = "value1" } 1 + + # HELP some_total2 A value that represents a counter. + # TYPE some_total2 counter + `, + metricNames: []string{"some_total2"}, + }, } for name, scenario := range scenarios { t.Run(name, func(t *testing.T) {