(t *testing.T)
| 408 | } |
| 409 | |
| 410 | func TestCollectAndCount(t *testing.T) { |
| 411 | c := prometheus.NewCounterVec( |
| 412 | prometheus.CounterOpts{ |
| 413 | Name: "some_total", |
| 414 | Help: "A value that represents a counter.", |
| 415 | }, |
| 416 | []string{"foo"}, |
| 417 | ) |
| 418 | if got, want := CollectAndCount(c), 0; got != want { |
| 419 | t.Errorf("unexpected metric count, got %d, want %d", got, want) |
| 420 | } |
| 421 | c.WithLabelValues("bar") |
| 422 | if got, want := CollectAndCount(c), 1; got != want { |
| 423 | t.Errorf("unexpected metric count, got %d, want %d", got, want) |
| 424 | } |
| 425 | c.WithLabelValues("baz") |
| 426 | if got, want := CollectAndCount(c), 2; got != want { |
| 427 | t.Errorf("unexpected metric count, got %d, want %d", got, want) |
| 428 | } |
| 429 | if got, want := CollectAndCount(c, "some_total"), 2; got != want { |
| 430 | t.Errorf("unexpected metric count, got %d, want %d", got, want) |
| 431 | } |
| 432 | if got, want := CollectAndCount(c, "some_other_total"), 0; got != want { |
| 433 | t.Errorf("unexpected metric count, got %d, want %d", got, want) |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | func TestCollectAndFormat(t *testing.T) { |
| 438 | const expected = `# HELP foo_bar A value that represents the number of bars in foo. |
nothing calls this directly
no test coverage detected