@@ -82,13 +82,15 @@ var _ = Describe("Network", func() {
82
82
})
83
83
84
84
// Sets expectations network tag creation. To be used by tests that get/create networks.
85
- expectNetworkTags := func (networkID string ) {
85
+ expectNetworkTags := func (networkID string , expectTagCreation bool ) {
86
86
listTagsParams := & cloudstack.ListTagsParams {}
87
87
createTagsParams := & cloudstack.CreateTagsParams {}
88
88
rs .EXPECT ().NewListTagsParams ().Return (listTagsParams )
89
89
rs .EXPECT ().ListTags (listTagsParams ).Return (& cloudstack.ListTagsResponse {}, nil )
90
- rs .EXPECT ().NewCreateTagsParams ([]string {networkID }, string (cloud .ResourceTypeNetwork ), gomock .Any ()).Return (createTagsParams )
91
- rs .EXPECT ().CreateTags (createTagsParams ).Return (& cloudstack.CreateTagsResponse {}, nil )
90
+ if expectTagCreation {
91
+ rs .EXPECT ().NewCreateTagsParams ([]string {networkID }, string (cloud .ResourceTypeNetwork ), gomock .Any ()).Return (createTagsParams )
92
+ rs .EXPECT ().CreateTags (createTagsParams ).Return (& cloudstack.CreateTagsResponse {}, nil )
93
+ }
92
94
}
93
95
94
96
Context ("for an existing network" , func () {
@@ -103,15 +105,15 @@ var _ = Describe("Network", func() {
103
105
It ("does not call to create a new network via GetOrCreateNetwork" , func () {
104
106
ns .EXPECT ().GetNetworkID (fakeNetName ).Return (fakeNetID , 1 , nil )
105
107
ns .EXPECT ().GetNetworkByID (fakeNetID ).Return (& cloudstack.Network {Type : isolatedNetworkType }, 1 , nil )
106
- expectNetworkTags (fakeNetID )
108
+ expectNetworkTags (fakeNetID , false )
107
109
108
110
Ω (client .GetOrCreateNetwork (csCluster )).Should (Succeed ())
109
111
})
110
112
111
113
It ("resolves network details with network ID instead of network name" , func () {
112
114
ns .EXPECT ().GetNetworkID (gomock .Any ()).Return ("" , - 1 , errors .New ("no match found for blah" ))
113
115
ns .EXPECT ().GetNetworkByID (fakeNetID ).Return (& cloudstack.Network {Type : isolatedNetworkType }, 1 , nil )
114
- expectNetworkTags (fakeNetID )
116
+ expectNetworkTags (fakeNetID , false )
115
117
116
118
csCluster .Spec .Network = fakeNetID
117
119
Ω (client .GetOrCreateNetwork (csCluster )).Should (Succeed ())
@@ -126,7 +128,7 @@ var _ = Describe("Network", func() {
126
128
ns .EXPECT ().NewCreateNetworkParams (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).
127
129
Return (& cloudstack.CreateNetworkParams {})
128
130
ns .EXPECT ().CreateNetwork (gomock .Any ()).Return (& cloudstack.CreateNetworkResponse {Id : netID }, nil )
129
- expectNetworkTags (netID )
131
+ expectNetworkTags (netID , true )
130
132
131
133
Ω (client .GetOrCreateNetwork (csCluster )).Should (Succeed ())
132
134
})
0 commit comments