@@ -207,6 +207,70 @@ var _ = Describe("Director", func() {
207207 })
208208 })
209209
210+ When ("there are existing azs and the clusters have the same name" , func () {
211+ BeforeEach (func () {
212+ server .AppendHandlers (
213+ ghttp .CombineHandlers (
214+ ghttp .VerifyRequest ("GET" , "/api/v0/staged/director/iaas_configurations" ),
215+ ghttp .RespondWith (http .StatusOK , `{
216+ "iaas_configurations": [{
217+ "guid": "existing-iaas-guid",
218+ "name": "existing-iaas"
219+ }]
220+ }` ),
221+ ),
222+ ghttp .CombineHandlers (
223+ ghttp .VerifyRequest ("GET" , "/api/v0/staged/director/availability_zones" ),
224+ ghttp .RespondWith (http .StatusOK , `{
225+ "availability_zones": [{
226+ "guid": "existing-az-guid",
227+ "name": "existing-az",
228+ "clusters": [
229+ { "cluster":"pizza", "guid":"pepperoni", "res_pool":"dcba"},
230+ { "cluster":"pizza", "guid":"ricotta", "res_pool":"abcd"}
231+ ]
232+ }]
233+ }` ),
234+ ),
235+ )
236+ })
237+
238+ It ("correctly matches the existing clusters within the az" , func () {
239+ server .AppendHandlers (
240+ ghttp .CombineHandlers (
241+ ghttp .VerifyRequest ("PUT" , "/api/v0/staged/director/availability_zones/existing-az-guid" ),
242+ ghttp .VerifyJSON (`{
243+ "availability_zone": {
244+ "a_field": "some_val",
245+ "guid": "existing-az-guid",
246+ "name": "existing-az",
247+ "iaas_configuration_guid": "existing-iaas-guid",
248+ "clusters": [
249+ { "cluster":"pizza", "guid":"pepperoni", "res_pool":"dcba"},
250+ { "cluster":"pizza", "guid":"ricotta", "res_pool":"abcd"}
251+ ]
252+ }
253+ }` ),
254+ ghttp .RespondWith (http .StatusOK , `{}` ),
255+ ),
256+ )
257+ err := service .UpdateStagedDirectorAvailabilityZones (api.AvailabilityZoneInput {
258+ AvailabilityZones : json .RawMessage (`[
259+ {
260+ "clusters": [
261+ {"cluster": "pizza", "guid":"pepperoni", "res_pool": "dcba"},
262+ {"cluster": "pizza", "guid":"ricotta", "res_pool": "abcd"}
263+ ],
264+ "iaas_configuration_name": "existing-iaas",
265+ "name": "existing-az",
266+ "a_field":"some_val"
267+ }
268+ ]` ),
269+ }, false )
270+ Expect (err ).ToNot (HaveOccurred ())
271+ })
272+ })
273+
210274 When ("there is only 1 az config passed in without a name and only 1 iaas config is returned by the api" , func () {
211275 It ("send the request anyway" , func () {
212276 server .AppendHandlers (
@@ -466,7 +530,7 @@ var _ = Describe("Director", func() {
466530 ghttp .VerifyHeader (map [string ][]string {"Content-Type" : []string {"application/json" }}),
467531 ghttp .RespondWith (http .StatusOK , `{
468532 "networks": [{
469- "guid": "existing-network-guid",
533+ "guid": "existing-network-guid",
470534 "name": "existing-network"
471535 }]
472536 }` ),
0 commit comments