@@ -31,22 +31,25 @@ func TestValidateResourceQuantity(t *testing.T) {
31
31
32
32
func TestValidateTPUNodeSelector (t * testing.T ) {
33
33
tests := []struct {
34
- nodeSelector map [ string ] string
34
+ tpu string
35
35
numOfHosts int32
36
+ nodeSelector map [string ]string
36
37
wantErr bool
37
38
}{
38
- {map [string ]string {}, 1 , true },
39
- {map [string ]string {NodeSelectorGKETPUAccelerator : "v2" }, 1 , true },
40
- {map [string ]string {NodeSelectorGKETPUTopology : "topology-1" }, 1 , true },
41
- {map [string ]string {NodeSelectorGKETPUAccelerator : "v2" , NodeSelectorGKETPUTopology : "topology-1" }, 0 , true },
42
- {map [string ]string {NodeSelectorGKETPUAccelerator : "v2" }, 0 , true },
43
- {map [string ]string {NodeSelectorGKETPUTopology : "topology-1" }, 0 , true },
44
- {map [string ]string {NodeSelectorGKETPUAccelerator : "v2" , NodeSelectorGKETPUTopology : "topology-1" }, 1 , false },
39
+ {"" , 1 , map [string ]string {}, false },
40
+ {"0" , 1 , map [string ]string {}, false },
41
+ {"1" , 1 , map [string ]string {}, true },
42
+ {"1" , 1 , map [string ]string {NodeSelectorGKETPUAccelerator : "v2" }, true },
43
+ {"1" , 1 , map [string ]string {NodeSelectorGKETPUTopology : "topology-1" }, true },
44
+ {"1" , 0 , map [string ]string {NodeSelectorGKETPUAccelerator : "v2" , NodeSelectorGKETPUTopology : "topology-1" }, true },
45
+ {"1" , 0 , map [string ]string {NodeSelectorGKETPUAccelerator : "v2" }, true },
46
+ {"1" , 0 , map [string ]string {NodeSelectorGKETPUTopology : "topology-1" }, true },
47
+ {"1" , 1 , map [string ]string {NodeSelectorGKETPUAccelerator : "v2" , NodeSelectorGKETPUTopology : "topology-1" }, false },
45
48
}
46
49
47
50
for _ , tt := range tests {
48
51
t .Run (fmt .Sprintf ("%v" , tt .nodeSelector ), func (t * testing.T ) {
49
- err := ValidateTPUNodeSelector ( tt .numOfHosts , tt .nodeSelector )
52
+ err := ValidateTPU ( & tt . tpu , & tt .numOfHosts , tt .nodeSelector )
50
53
if (err != nil ) != tt .wantErr {
51
54
t .Errorf ("ValidateTPUNodeSelector() = %v, wantErr %v" , err , tt .wantErr )
52
55
}
0 commit comments