(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestNewConstMetricInvalidLabelValues(t *testing.T) { |
| 25 | testCases := []struct { |
| 26 | desc string |
| 27 | labels Labels |
| 28 | }{ |
| 29 | { |
| 30 | desc: "non utf8 label value", |
| 31 | labels: Labels{"a": "\xFF"}, |
| 32 | }, |
| 33 | { |
| 34 | desc: "not enough label values", |
| 35 | labels: Labels{}, |
| 36 | }, |
| 37 | { |
| 38 | desc: "too many label values", |
| 39 | labels: Labels{"a": "1", "b": "2"}, |
| 40 | }, |
| 41 | } |
| 42 | |
| 43 | for _, test := range testCases { |
| 44 | metricDesc := NewDesc( |
| 45 | "sample_value", |
| 46 | "sample value", |
| 47 | []string{"a"}, |
| 48 | Labels{}, |
| 49 | ) |
| 50 | |
| 51 | expectPanic(t, func() { |
| 52 | MustNewConstMetric(metricDesc, CounterValue, 0.3, "\xFF") |
| 53 | }, "WithLabelValues: expected panic because: "+test.desc) |
| 54 | |
| 55 | if _, err := NewConstMetric(metricDesc, CounterValue, 0.3, "\xFF"); err == nil { |
| 56 | t.Errorf("NewConstMetric: expected error because: %s", test.desc) |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func TestNewConstMetricWithCreatedTimestamp(t *testing.T) { |
| 62 | now := time.Now() |
nothing calls this directly
no test coverage detected