Skip to content

Commit 2b2d8e8

Browse files
committed
add test
1 parent e79d121 commit 2b2d8e8

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

cloud/nodeipam/ipam/cloud_allocator_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,40 @@ type testCase struct {
5050
instance *linodego.Instance
5151
}
5252

53+
func TestGetIPv6RangeFromLinodeInterface(t *testing.T) {
54+
for _, tc := range []struct {
55+
iface linodego.LinodeInterface
56+
expectedRange string
57+
}{
58+
{linodego.LinodeInterface{
59+
ID: 123,
60+
VPC: &linodego.VPCInterface{
61+
IPv6: linodego.VPCInterfaceIPv6{},
62+
},
63+
}, ""},
64+
{linodego.LinodeInterface{
65+
ID: 123,
66+
VPC: &linodego.VPCInterface{
67+
IPv6: linodego.VPCInterfaceIPv6{
68+
Ranges: []linodego.VPCInterfaceIPv6Range{{Range: "2001:db8::/64"}, {Range: "2001:db9::/64"}},
69+
},
70+
},
71+
}, "2001:db8::/64"},
72+
{linodego.LinodeInterface{
73+
ID: 123,
74+
VPC: &linodego.VPCInterface{
75+
IPv6: linodego.VPCInterfaceIPv6{
76+
SLAAC: []linodego.VPCInterfaceIPv6SLAAC{{Range: "2001:db8::/64"}, {Range: "2001:db9::/64"}},
77+
},
78+
},
79+
}, "2001:db8::/64"},
80+
} {
81+
if getIPv6RangeFromLinodeInterface(tc.iface) != tc.expectedRange {
82+
t.Errorf("getIPv6RangeFromLinodeInterface(%+v) = %s, want %s", tc.iface, getIPv6RangeFromLinodeInterface(tc.iface), tc.expectedRange)
83+
}
84+
}
85+
}
86+
5387
func TestOccupyPreExistingCIDR(t *testing.T) {
5488
// all tests operate on a single node
5589
ctrl := gomock.NewController(t)

0 commit comments

Comments
 (0)