(t *testing.T)
| 435 | } |
| 436 | |
| 437 | func TestCollectAndFormat(t *testing.T) { |
| 438 | const expected = `# HELP foo_bar A value that represents the number of bars in foo. |
| 439 | # TYPE foo_bar counter |
| 440 | foo_bar{fizz="bang"} 1 |
| 441 | ` |
| 442 | c := prometheus.NewCounterVec( |
| 443 | prometheus.CounterOpts{ |
| 444 | Name: "foo_bar", |
| 445 | Help: "A value that represents the number of bars in foo.", |
| 446 | }, |
| 447 | []string{"fizz"}, |
| 448 | ) |
| 449 | c.WithLabelValues("bang").Inc() |
| 450 | |
| 451 | got, err := CollectAndFormat(c, expfmt.TypeTextPlain, "foo_bar") |
| 452 | if err != nil { |
| 453 | t.Errorf("unexpected error: %s", err.Error()) |
| 454 | } |
| 455 | |
| 456 | gotS := string(got) |
| 457 | if err != nil { |
| 458 | t.Errorf("unexpected error: %s", err.Error()) |
| 459 | } |
| 460 | |
| 461 | if gotS != expected { |
| 462 | t.Errorf("unexpected metric output, got %q, expected %q", gotS, expected) |
| 463 | } |
| 464 | } |
nothing calls this directly
no test coverage detected