-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathlabels_test.go
More file actions
55 lines (48 loc) · 1.12 KB
/
labels_test.go
File metadata and controls
55 lines (48 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package agentmetrics_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/coderd/agentmetrics"
)
func TestValidateAggregationLabels(t *testing.T) {
t.Parallel()
tests := []struct {
name string
labels []string
expectedErr bool
}{
{
name: "empty list is valid",
},
{
name: "single valid entry",
labels: []string{agentmetrics.LabelTemplateName},
},
{
name: "multiple valid entries",
labels: []string{agentmetrics.LabelTemplateName, agentmetrics.LabelUsername},
},
{
name: "repeated valid entries are not invalid",
labels: []string{agentmetrics.LabelTemplateName, agentmetrics.LabelUsername, agentmetrics.LabelUsername, agentmetrics.LabelUsername},
},
{
name: "empty entry is invalid",
labels: []string{""},
expectedErr: true,
},
{
name: "all valid entries",
labels: agentmetrics.LabelAll,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
err := agentmetrics.ValidateAggregationLabels(tc.labels)
if tc.expectedErr {
require.Error(t, err)
}
})
}
}