@@ -37,6 +37,7 @@ var _ = Describe("Network", func() {
37
37
fs * cloudstack.MockFirewallServiceIface
38
38
as * cloudstack.MockAddressServiceIface
39
39
lbs * cloudstack.MockLoadBalancerServiceIface
40
+ rs * cloudstack.MockResourcetagsServiceIface
40
41
csCluster * infrav1.CloudStackCluster
41
42
client cloud.Client
42
43
)
@@ -60,6 +61,7 @@ var _ = Describe("Network", func() {
60
61
fs = mockClient .Firewall .(* cloudstack.MockFirewallServiceIface )
61
62
as = mockClient .Address .(* cloudstack.MockAddressServiceIface )
62
63
lbs = mockClient .LoadBalancer .(* cloudstack.MockLoadBalancerServiceIface )
64
+ rs = mockClient .Resourcetags .(* cloudstack.MockResourcetagsServiceIface )
63
65
client = cloud .NewClientFromCSAPIClient (mockClient )
64
66
65
67
// Reset csCluster.
@@ -91,13 +93,21 @@ var _ = Describe("Network", func() {
91
93
It ("does not call to create a new network via GetOrCreateNetwork" , func () {
92
94
ns .EXPECT ().GetNetworkID (fakeNetName ).Return (fakeNetId , 1 , nil )
93
95
ns .EXPECT ().GetNetworkByID (fakeNetId ).Return (& cloudstack.Network {Type : isolatedNetworkType }, 1 , nil )
96
+ rs .EXPECT ().NewListTagsParams ().Return (& cloudstack.ListTagsParams {})
97
+ rs .EXPECT ().ListTags (gomock .Any ()).Return (& cloudstack.ListTagsResponse {}, nil )
98
+ rs .EXPECT ().NewCreateTagsParams (gomock .Any (), gomock .Any (), gomock .Any ()).Return (& cloudstack.CreateTagsParams {})
99
+ rs .EXPECT ().CreateTags (gomock .Any ()).Return (& cloudstack.CreateTagsResponse {}, nil )
94
100
95
101
Ω (client .GetOrCreateNetwork (csCluster )).Should (Succeed ())
96
102
})
97
103
98
104
It ("resolves network details with network ID instead of network name" , func () {
99
105
ns .EXPECT ().GetNetworkID (gomock .Any ()).Return ("" , - 1 , errors .New ("No match found for blah." ))
100
106
ns .EXPECT ().GetNetworkByID (fakeNetId ).Return (& cloudstack.Network {Type : isolatedNetworkType }, 1 , nil )
107
+ rs .EXPECT ().NewListTagsParams ().Return (& cloudstack.ListTagsParams {})
108
+ rs .EXPECT ().ListTags (gomock .Any ()).Return (& cloudstack.ListTagsResponse {}, nil )
109
+ rs .EXPECT ().NewCreateTagsParams (gomock .Any (), gomock .Any (), gomock .Any ()).Return (& cloudstack.CreateTagsParams {})
110
+ rs .EXPECT ().CreateTags (gomock .Any ()).Return (& cloudstack.CreateTagsResponse {}, nil )
101
111
102
112
csCluster .Spec .Network = fakeNetId
103
113
Ω (client .GetOrCreateNetwork (csCluster )).Should (Succeed ())
@@ -112,6 +122,10 @@ var _ = Describe("Network", func() {
112
122
ns .EXPECT ().NewCreateNetworkParams (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).
113
123
Return (& cloudstack.CreateNetworkParams {})
114
124
ns .EXPECT ().CreateNetwork (gomock .Any ()).Return (& cloudstack.CreateNetworkResponse {Id : netId }, nil )
125
+ rs .EXPECT ().NewListTagsParams ().Return (& cloudstack.ListTagsParams {})
126
+ rs .EXPECT ().ListTags (gomock .Any ()).Return (& cloudstack.ListTagsResponse {}, nil )
127
+ rs .EXPECT ().NewCreateTagsParams (gomock .Any (), gomock .Any (), gomock .Any ()).Return (& cloudstack.CreateTagsParams {})
128
+ rs .EXPECT ().CreateTags (gomock .Any ()).Return (& cloudstack.CreateTagsResponse {}, nil )
115
129
Ω (client .GetOrCreateNetwork (csCluster )).Should (Succeed ())
116
130
})
117
131
})
0 commit comments