testutil: add compare test with absent metric

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
This commit is contained in:
Damien Grisonnet 2024-10-10 21:16:18 +02:00
parent 93c851f0b3
commit ae94210a89
1 changed files with 12 additions and 0 deletions

View File

@ -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) {