Skip to content

Commit 82d41ad

Browse files
committed
Fixed broken tests
1 parent fd4ce5e commit 82d41ad

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/cloud/network_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var _ = Describe("Network", func() {
3737
fs *cloudstack.MockFirewallServiceIface
3838
as *cloudstack.MockAddressServiceIface
3939
lbs *cloudstack.MockLoadBalancerServiceIface
40+
rs *cloudstack.MockResourcetagsServiceIface
4041
csCluster *infrav1.CloudStackCluster
4142
client cloud.Client
4243
)
@@ -60,6 +61,7 @@ var _ = Describe("Network", func() {
6061
fs = mockClient.Firewall.(*cloudstack.MockFirewallServiceIface)
6162
as = mockClient.Address.(*cloudstack.MockAddressServiceIface)
6263
lbs = mockClient.LoadBalancer.(*cloudstack.MockLoadBalancerServiceIface)
64+
rs = mockClient.Resourcetags.(*cloudstack.MockResourcetagsServiceIface)
6365
client = cloud.NewClientFromCSAPIClient(mockClient)
6466

6567
// Reset csCluster.
@@ -91,13 +93,21 @@ var _ = Describe("Network", func() {
9193
It("does not call to create a new network via GetOrCreateNetwork", func() {
9294
ns.EXPECT().GetNetworkID(fakeNetName).Return(fakeNetId, 1, nil)
9395
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)
94100

95101
Ω(client.GetOrCreateNetwork(csCluster)).Should(Succeed())
96102
})
97103

98104
It("resolves network details with network ID instead of network name", func() {
99105
ns.EXPECT().GetNetworkID(gomock.Any()).Return("", -1, errors.New("No match found for blah."))
100106
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)
101111

102112
csCluster.Spec.Network = fakeNetId
103113
Ω(client.GetOrCreateNetwork(csCluster)).Should(Succeed())
@@ -112,6 +122,10 @@ var _ = Describe("Network", func() {
112122
ns.EXPECT().NewCreateNetworkParams(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
113123
Return(&cloudstack.CreateNetworkParams{})
114124
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)
115129
Ω(client.GetOrCreateNetwork(csCluster)).Should(Succeed())
116130
})
117131
})

0 commit comments

Comments
 (0)