(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func TestLabelCheck(t *testing.T) { |
| 28 | scenarios := map[string]struct { |
| 29 | metricName string // Defaults to "c". |
| 30 | varLabels []string |
| 31 | constLabels []string |
| 32 | curriedLabels []string |
| 33 | dynamicLabels []string |
| 34 | ok bool |
| 35 | }{ |
| 36 | "empty": { |
| 37 | varLabels: []string{}, |
| 38 | constLabels: []string{}, |
| 39 | curriedLabels: []string{}, |
| 40 | ok: true, |
| 41 | }, |
| 42 | "code as single var label": { |
| 43 | varLabels: []string{"code"}, |
| 44 | constLabels: []string{}, |
| 45 | curriedLabels: []string{}, |
| 46 | ok: true, |
| 47 | }, |
| 48 | "method as single var label": { |
| 49 | varLabels: []string{"method"}, |
| 50 | constLabels: []string{}, |
| 51 | curriedLabels: []string{}, |
| 52 | ok: true, |
| 53 | }, |
| 54 | "code and method as var labels": { |
| 55 | varLabels: []string{"method", "code"}, |
| 56 | constLabels: []string{}, |
| 57 | curriedLabels: []string{}, |
| 58 | ok: true, |
| 59 | }, |
| 60 | "valid case with all labels used": { |
| 61 | varLabels: []string{"code", "method"}, |
| 62 | constLabels: []string{"foo", "bar"}, |
| 63 | curriedLabels: []string{"dings", "bums"}, |
| 64 | dynamicLabels: []string{"dyn", "amics"}, |
| 65 | ok: true, |
| 66 | }, |
| 67 | "all labels used with an invalid const label name": { |
| 68 | varLabels: []string{"code", "method"}, |
| 69 | constLabels: []string{"in\x80valid", "bar"}, |
| 70 | curriedLabels: []string{"dings", "bums"}, |
| 71 | dynamicLabels: []string{"dyn", "amics"}, |
| 72 | ok: false, |
| 73 | }, |
| 74 | "unsupported var label": { |
| 75 | varLabels: []string{"foo"}, |
| 76 | constLabels: []string{}, |
| 77 | curriedLabels: []string{}, |
| 78 | ok: false, |
| 79 | }, |
| 80 | "mixed var labels": { |
| 81 | varLabels: []string{"method", "foo", "code"}, |
| 82 | constLabels: []string{}, |
| 83 | curriedLabels: []string{}, |
| 84 | ok: false, |
nothing calls this directly
no test coverage detected