nodeipam-controller:fix static check failures

This commit is contained in:
shivi28 2019-08-30 01:50:04 +05:30 committed by Shivani Singhal
parent 3b58b35921
commit a0109f00df
2 changed files with 31 additions and 27 deletions

View File

@ -12,7 +12,6 @@ pkg/controller/disruption
pkg/controller/garbagecollector pkg/controller/garbagecollector
pkg/controller/namespace/deletion pkg/controller/namespace/deletion
pkg/controller/nodeipam pkg/controller/nodeipam
pkg/controller/nodeipam/ipam/cidrset
pkg/controller/podautoscaler pkg/controller/podautoscaler
pkg/controller/podgc pkg/controller/podgc
pkg/controller/replicaset pkg/controller/replicaset

View File

@ -700,34 +700,39 @@ func TestCIDRSetv6(t *testing.T) {
}, },
} }
for _, tc := range cases { for _, tc := range cases {
t.Run(tc.description, func(t *testing.T) {
_, clusterCIDR, _ := net.ParseCIDR(tc.clusterCIDRStr) _, clusterCIDR, _ := net.ParseCIDR(tc.clusterCIDRStr)
a, err := NewCIDRSet(clusterCIDR, tc.subNetMaskSize) a, err := NewCIDRSet(clusterCIDR, tc.subNetMaskSize)
if err != nil { if gotErr := err != nil; gotErr != tc.expectErr {
if tc.expectErr { t.Fatalf("NewCIDRSet(%v, %v) = %v, %v; gotErr = %t, want %t", clusterCIDR, tc.subNetMaskSize, a, err, gotErr, tc.expectErr)
continue
} }
t.Fatalf("Error allocating CIDRSet for %v", tc.description) if a == nil {
return
} }
p, err := a.AllocateNext() p, err := a.AllocateNext()
if err == nil && tc.expectErr { if err == nil && tc.expectErr {
t.Errorf("expected error but got none for %v", tc.description) t.Errorf("a.AllocateNext() = nil, want error")
continue
} }
if err != nil && !tc.expectErr { if err != nil && !tc.expectErr {
t.Errorf("unexpected error: %v for %v", err, tc.description) t.Errorf("a.AllocateNext() = %+v, want no error", err)
continue
} }
if !tc.expectErr { if !tc.expectErr {
if p.String() != tc.expectedCIDR { if p != nil && p.String() != tc.expectedCIDR {
t.Fatalf("unexpected allocated cidr: %s for %v", p.String(), tc.description) t.Fatalf("a.AllocateNext() got %+v, want %+v", p.String(), tc.expectedCIDR)
} }
} }
p2, err := a.AllocateNext() p2, err := a.AllocateNext()
if err == nil && tc.expectErr {
t.Errorf("a.AllocateNext() = nil, want error")
}
if err != nil && !tc.expectErr {
t.Errorf("a.AllocateNext() = %+v, want no error", err)
}
if !tc.expectErr { if !tc.expectErr {
if p2.String() != tc.expectedCIDR2 { if p2 != nil && p2.String() != tc.expectedCIDR2 {
t.Fatalf("unexpected allocated cidr: %s for %v", p2.String(), tc.description) t.Fatalf("a.AllocateNext() got %+v, want %+v", p2.String(), tc.expectedCIDR)
} }
} }
})
} }
} }