(t *testing.T)
| 33 | } |
| 34 | |
| 35 | func Test_buildLabelSets(t *testing.T) { |
| 36 | testcases := map[string]struct { |
| 37 | labels []string |
| 38 | labelValues map[string][]string |
| 39 | expected []prometheus.Labels |
| 40 | }{ |
| 41 | "single label, single value": { |
| 42 | labels: []string{"operation"}, |
| 43 | labelValues: map[string][]string{ |
| 44 | "operation": {"insert"}, |
| 45 | }, |
| 46 | expected: []prometheus.Labels{ |
| 47 | map[string]string{"operation": "insert"}, |
| 48 | }, |
| 49 | }, |
| 50 | "single label, multiple values": { |
| 51 | labels: []string{"operation"}, |
| 52 | labelValues: map[string][]string{ |
| 53 | "operation": {"insert", "delete"}, |
| 54 | }, |
| 55 | expected: []prometheus.Labels{ |
| 56 | map[string]string{"operation": "insert"}, |
| 57 | map[string]string{"operation": "delete"}, |
| 58 | }, |
| 59 | }, |
| 60 | "multiple label, single value": { |
| 61 | labels: []string{"operation", "success"}, |
| 62 | labelValues: map[string][]string{ |
| 63 | "operation": {"insert"}, |
| 64 | "success": {"true"}, |
| 65 | }, |
| 66 | expected: []prometheus.Labels{ |
| 67 | map[string]string{"operation": "insert", "success": "true"}, |
| 68 | }, |
| 69 | }, |
| 70 | "multiple label, multiple values": { |
| 71 | labels: []string{"operation", "success"}, |
| 72 | labelValues: map[string][]string{ |
| 73 | "operation": {"insert", "delete"}, |
| 74 | "success": {"true", "false"}, |
| 75 | }, |
| 76 | expected: []prometheus.Labels{ |
| 77 | map[string]string{"operation": "insert", "success": "true"}, |
| 78 | map[string]string{"operation": "insert", "success": "false"}, |
| 79 | map[string]string{"operation": "delete", "success": "true"}, |
| 80 | map[string]string{"operation": "delete", "success": "false"}, |
| 81 | }, |
| 82 | }, |
| 83 | "irregular labels and values": { |
| 84 | labels: []string{"operation", "success", "environment"}, |
| 85 | labelValues: map[string][]string{ |
| 86 | "operation": {"insert", "update", "delete"}, |
| 87 | "success": {"true", "false"}, |
| 88 | "environment": {"dev", "test", "staging"}, |
| 89 | }, |
| 90 | expected: []prometheus.Labels{ |
| 91 | map[string]string{"operation": "insert", "success": "true", "environment": "dev"}, |
| 92 | map[string]string{"operation": "insert", "success": "true", "environment": "test"}, |
nothing calls this directly
no test coverage detected