File tree 1 file changed +25
-0
lines changed 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,31 @@ func TestScrapeAndCompare(t *testing.T) {
331
331
}
332
332
}
333
333
334
+ func TestScrapeAndCompareWithMultipleExpected (t * testing.T ) {
335
+ const expected = `
336
+ # HELP some_total A value that represents a counter.
337
+ # TYPE some_total counter
338
+
339
+ some_total{ label1 = "value1" } 1
340
+
341
+ # HELP some_total2 A value that represents a counter.
342
+ # TYPE some_total2 counter
343
+
344
+ some_total2{ label1 = "value1" } 1
345
+ `
346
+
347
+ expectedReader := strings .NewReader (expected )
348
+
349
+ ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
350
+ fmt .Fprintln (w , expected )
351
+ }))
352
+ defer ts .Close ()
353
+
354
+ if err := ScrapeAndCompare (ts .URL , expectedReader , "some_total2" ); err != nil {
355
+ t .Errorf ("unexpected scraping result:\n %s" , err )
356
+ }
357
+ }
358
+
334
359
func TestScrapeAndCompareFetchingFail (t * testing.T ) {
335
360
err := ScrapeAndCompare ("some_url" , strings .NewReader ("some expectation" ), "some_total" )
336
361
if err == nil {
You can’t perform that action at this time.
0 commit comments