(t *testing.T, name string, labels map[string]string, wantMin float64)
| 143 | } |
| 144 | |
| 145 | func assertCounter(t *testing.T, name string, labels map[string]string, wantMin float64) { |
| 146 | t.Helper() |
| 147 | families, err := prometheus.DefaultGatherer.Gather() |
| 148 | require.NoError(t, err) |
| 149 | |
| 150 | var found bool |
| 151 | for _, f := range families { |
| 152 | if f.GetName() != name { |
| 153 | continue |
| 154 | } |
| 155 | for _, m := range f.Metric { |
| 156 | if matchesLabels(m.Label, labels) { |
| 157 | found = true |
| 158 | if m.GetCounter() != nil { |
| 159 | assert.GreaterOrEqual(t, m.GetCounter().GetValue(), wantMin) |
| 160 | } else { |
| 161 | t.Fatalf("metric %s is not a counter", name) |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | assert.True(t, found, "metric %s with labels %v not found", name, labels) |
| 167 | } |
| 168 | |
| 169 | func assertGauge(t *testing.T, name string, want float64) { |
| 170 | t.Helper() |
no test coverage detected
searching dependent graphs…