(t *testing.T)
| 124 | } |
| 125 | |
| 126 | func TestCollectAndCompare(t *testing.T) { |
| 127 | const metadata = ` |
| 128 | # HELP some_total A value that represents a counter. |
| 129 | # TYPE some_total counter |
| 130 | ` |
| 131 | |
| 132 | c := prometheus.NewCounter(prometheus.CounterOpts{ |
| 133 | Name: "some_total", |
| 134 | Help: "A value that represents a counter.", |
| 135 | ConstLabels: prometheus.Labels{ |
| 136 | "label1": "value1", |
| 137 | }, |
| 138 | }) |
| 139 | c.Inc() |
| 140 | |
| 141 | expected := ` |
| 142 | |
| 143 | some_total{ label1 = "value1" } 1 |
| 144 | ` |
| 145 | |
| 146 | if err := CollectAndCompare(c, strings.NewReader(metadata+expected), "some_total"); err != nil { |
| 147 | t.Errorf("unexpected collecting result:\n%s", err) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func TestCollectAndCompareNoLabel(t *testing.T) { |
| 152 | const metadata = ` |
nothing calls this directly
no test coverage detected