forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgroup_test.go
66 lines (55 loc) · 1.61 KB
/
group_test.go
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
56
57
58
59
60
61
62
63
64
65
66
package api
import (
"testing"
"k8s.io/kubernetes/pkg/util/sets"
)
func TestEscalating(t *testing.T) {
escalatingResources := NormalizeResources(sets.NewString(GroupsToResources[EscalatingResourcesGroupName]...))
nonEscalatingResources := NormalizeResources(sets.NewString(GroupsToResources[NonEscalatingResourcesGroupName]...))
if len(nonEscalatingResources) <= len(escalatingResources) {
t.Errorf("groups look bad: escalating=%v nonescalating=%v", escalatingResources.List(), nonEscalatingResources.List())
}
}
func TestNormalizeResources(t *testing.T) {
tests := []struct {
name string
resource string
expected string
}{
{"capA", "capA", "capa"},
{"capH", "capH", "caph"},
{"capZ", "capZ", "capz"},
{"group", BuildGroupName, "builds"},
}
for _, test := range tests {
normalizedNames := NormalizeResources(sets.NewString(test.resource))
if !normalizedNames.Has(test.expected) {
t.Errorf("%s: expected %s, got %v", test.name, test.expected, normalizedNames)
}
}
}
func TestNeedsNormalization(t *testing.T) {
tests := []struct {
name string
resource string
expected bool
}{
{"cap", "G", true},
{"lowera", "lowera", false},
{"lowerh", "lowerh", false},
{"lowerz", "lowerz", false},
{"0", "0", false},
{"5", "5", false},
{"9", "9", false},
{"/", "/", false},
{"-", "-", false},
{".", ".", false},
{ResourceGroupPrefix, ResourceGroupPrefix, true},
}
for _, test := range tests {
needsNormalizing := needsNormalizing(test.resource)
if needsNormalizing != test.expected {
t.Errorf("%s: expected %v, got %v", test.name, test.expected, needsNormalizing)
}
}
}