-
Notifications
You must be signed in to change notification settings - Fork 5
/
openstackrouter_controller_test.go
63 lines (60 loc) · 1.78 KB
/
openstackrouter_controller_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
package controller
import (
"testing"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers"
)
func TestRouterEquals(t *testing.T) {
for _, tc := range [...]struct {
name string
candidate routers.Router
opts routers.CreateOpts
expected bool
}{
{
name: "same external fixed IPs",
candidate: routers.Router{
GatewayInfo: routers.GatewayInfo{
ExternalFixedIPs: []routers.ExternalFixedIP{
{IPAddress: "10.0.0.1", SubnetID: "06125cfa-fe0d-40c7-af74-d3f11140f2e0"},
{IPAddress: "10.0.0.2", SubnetID: "06125cfa-fe0d-40c7-af74-d3f11140f2e1"},
},
},
},
opts: routers.CreateOpts{
GatewayInfo: &routers.GatewayInfo{
ExternalFixedIPs: []routers.ExternalFixedIP{
{IPAddress: "10.0.0.2", SubnetID: "06125cfa-fe0d-40c7-af74-d3f11140f2e1"},
{IPAddress: "10.0.0.1", SubnetID: "06125cfa-fe0d-40c7-af74-d3f11140f2e0"},
},
},
},
expected: true,
},
{
name: "different external fixed IPs",
candidate: routers.Router{
GatewayInfo: routers.GatewayInfo{
ExternalFixedIPs: []routers.ExternalFixedIP{
{IPAddress: "10.0.0.1", SubnetID: "06125cfa-fe0d-40c7-af74-d3f11140f2e0"},
{IPAddress: "10.0.0.2", SubnetID: "06125cfa-fe0d-40c7-af74-d3f11140f2e1"},
},
},
},
opts: routers.CreateOpts{
GatewayInfo: &routers.GatewayInfo{
ExternalFixedIPs: []routers.ExternalFixedIP{
{IPAddress: "10.0.0.2", SubnetID: "06125cfa-fe0d-40c7-af74-d3f11140f2e1"},
{IPAddress: "10.0.0.0", SubnetID: "06125cfa-fe0d-40c7-af74-d3f11140f2e0"},
},
},
},
expected: false,
},
} {
t.Run(tc.name, func(t *testing.T) {
if got := routerEquals(tc.candidate, tc.opts); got != tc.expected {
t.Errorf("expected %v, got %v", tc.expected, got)
}
})
}
}