(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestValidateAggregationLabels(t *testing.T) { |
| 12 | t.Parallel() |
| 13 | |
| 14 | tests := []struct { |
| 15 | name string |
| 16 | labels []string |
| 17 | expectedErr bool |
| 18 | }{ |
| 19 | { |
| 20 | name: "empty list is valid", |
| 21 | }, |
| 22 | { |
| 23 | name: "single valid entry", |
| 24 | labels: []string{agentmetrics.LabelTemplateName}, |
| 25 | }, |
| 26 | { |
| 27 | name: "multiple valid entries", |
| 28 | labels: []string{agentmetrics.LabelTemplateName, agentmetrics.LabelUsername}, |
| 29 | }, |
| 30 | { |
| 31 | name: "repeated valid entries are not invalid", |
| 32 | labels: []string{agentmetrics.LabelTemplateName, agentmetrics.LabelUsername, agentmetrics.LabelUsername, agentmetrics.LabelUsername}, |
| 33 | }, |
| 34 | { |
| 35 | name: "empty entry is invalid", |
| 36 | labels: []string{""}, |
| 37 | expectedErr: true, |
| 38 | }, |
| 39 | { |
| 40 | name: "all valid entries", |
| 41 | labels: agentmetrics.LabelAll, |
| 42 | }, |
| 43 | } |
| 44 | |
| 45 | for _, tc := range tests { |
| 46 | t.Run(tc.name, func(t *testing.T) { |
| 47 | t.Parallel() |
| 48 | |
| 49 | err := agentmetrics.ValidateAggregationLabels(tc.labels) |
| 50 | if tc.expectedErr { |
| 51 | require.Error(t, err) |
| 52 | } |
| 53 | }) |
| 54 | } |
| 55 | } |
nothing calls this directly
no test coverage detected