@@ -37,20 +37,23 @@ var _ = Describe("ApplyAggregates", func() {
3737 "availability_zone": "az1",
3838 "deleted": false,
3939 "id": 1,
40+ "uuid": "uuid-agg1",
4041 "hosts": ["test-host"]
4142 },
4243 {
4344 "name": "agg2",
4445 "availability_zone": "az2",
4546 "deleted": false,
4647 "id": 2,
48+ "uuid": "uuid-agg2",
4749 "hosts": ["test-host"]
4850 },
4951 {
5052 "name": "agg3",
5153 "availability_zone": "az3",
5254 "deleted": false,
5355 "id": 3,
56+ "uuid": "uuid-agg3",
5457 "hosts": []
5558 }
5659 ]
@@ -62,6 +65,7 @@ var _ = Describe("ApplyAggregates", func() {
6265 "availability_zone": "az3",
6366 "deleted": false,
6467 "id": 3,
68+ "uuid": "uuid-agg3",
6569 "hosts": ["test-host"]
6670 }
6771 }`
@@ -72,6 +76,7 @@ var _ = Describe("ApplyAggregates", func() {
7276 "availability_zone": "az1",
7377 "deleted": false,
7478 "id": 1,
79+ "uuid": "uuid-agg1",
7580 "hosts": []
7681 }
7782 }`
@@ -108,8 +113,9 @@ var _ = Describe("ApplyAggregates", func() {
108113
109114 It ("should add host to agg3" , func () {
110115 serviceClient := client .ServiceClient (fakeServer )
111- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" , "agg2" , "agg3" })
116+ uuids , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" , "agg2" , "agg3" })
112117 Expect (err ).NotTo (HaveOccurred ())
118+ Expect (uuids ).To (ConsistOf ("uuid-agg1" , "uuid-agg2" , "uuid-agg3" ))
113119 })
114120 })
115121
@@ -130,8 +136,9 @@ var _ = Describe("ApplyAggregates", func() {
130136
131137 It ("should remove host from agg1" , func () {
132138 serviceClient := client .ServiceClient (fakeServer )
133- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg2" })
139+ uuids , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg2" })
134140 Expect (err ).NotTo (HaveOccurred ())
141+ Expect (uuids ).To (ConsistOf ("uuid-agg2" ))
135142 })
136143 })
137144
@@ -158,15 +165,16 @@ var _ = Describe("ApplyAggregates", func() {
158165 removeCalls ++
159166 w .Header ().Add ("Content-Type" , "application/json" )
160167 w .WriteHeader (http .StatusOK )
161- fmt .Fprint (w , `{"aggregate": {"name": "agg2", "id": 2, "hosts": []}}` )
168+ fmt .Fprint (w , `{"aggregate": {"name": "agg2", "id": 2, "uuid": "uuid-agg2", " hosts": []}}` )
162169 })
163170 })
164171
165172 It ("should remove host from all aggregates" , func () {
166173 serviceClient := client .ServiceClient (fakeServer )
167- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {})
174+ uuids , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {})
168175 Expect (err ).NotTo (HaveOccurred ())
169176 Expect (removeCalls ).To (Equal (2 ))
177+ Expect (uuids ).To (BeEmpty ())
170178 })
171179 })
172180
@@ -181,8 +189,9 @@ var _ = Describe("ApplyAggregates", func() {
181189
182190 It ("should not make any changes" , func () {
183191 serviceClient := client .ServiceClient (fakeServer )
184- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" , "agg2" })
192+ uuids , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" , "agg2" })
185193 Expect (err ).NotTo (HaveOccurred ())
194+ Expect (uuids ).To (ConsistOf ("uuid-agg1" , "uuid-agg2" ))
186195 })
187196 })
188197
@@ -209,8 +218,9 @@ var _ = Describe("ApplyAggregates", func() {
209218
210219 It ("should replace agg1 with agg3" , func () {
211220 serviceClient := client .ServiceClient (fakeServer )
212- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg2" , "agg3" })
221+ uuids , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg2" , "agg3" })
213222 Expect (err ).NotTo (HaveOccurred ())
223+ Expect (uuids ).To (ConsistOf ("uuid-agg2" , "uuid-agg3" ))
214224 })
215225 })
216226
@@ -224,7 +234,7 @@ var _ = Describe("ApplyAggregates", func() {
224234
225235 It ("should return an error" , func () {
226236 serviceClient := client .ServiceClient (fakeServer )
227- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" })
237+ _ , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" })
228238 Expect (err ).To (HaveOccurred ())
229239 Expect (err .Error ()).To (ContainSubstring ("failed to list aggregates" ))
230240 })
@@ -246,7 +256,7 @@ var _ = Describe("ApplyAggregates", func() {
246256
247257 It ("should return an error" , func () {
248258 serviceClient := client .ServiceClient (fakeServer )
249- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" , "agg2" , "agg3" })
259+ _ , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" , "agg2" , "agg3" })
250260 Expect (err ).To (HaveOccurred ())
251261 Expect (err .Error ()).To (ContainSubstring ("failed to add host" ))
252262 })
@@ -268,7 +278,7 @@ var _ = Describe("ApplyAggregates", func() {
268278
269279 It ("should return an error" , func () {
270280 serviceClient := client .ServiceClient (fakeServer )
271- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg2" })
281+ _ , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg2" })
272282 Expect (err ).To (HaveOccurred ())
273283 Expect (err .Error ()).To (ContainSubstring ("failed to remove host" ))
274284 })
@@ -291,8 +301,9 @@ var _ = Describe("ApplyAggregates", func() {
291301
292302 It ("should add new host to aggregate" , func () {
293303 serviceClient := client .ServiceClient (fakeServer )
294- err := ApplyAggregates (ctx , serviceClient , "new-host" , []string {"agg3" })
304+ uuids , err := ApplyAggregates (ctx , serviceClient , "new-host" , []string {"agg3" })
295305 Expect (err ).NotTo (HaveOccurred ())
306+ Expect (uuids ).To (ConsistOf ("uuid-agg3" ))
296307 })
297308 })
298309
@@ -319,7 +330,7 @@ var _ = Describe("ApplyAggregates", func() {
319330
320331 It ("should return combined errors" , func () {
321332 serviceClient := client .ServiceClient (fakeServer )
322- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg2" , "agg3" })
333+ _ , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg2" , "agg3" })
323334 Expect (err ).To (HaveOccurred ())
324335 // Verify it's a joined error with multiple failures
325336 Expect (err .Error ()).To (And (ContainSubstring ("failed to add host" ), ContainSubstring ("failed to remove host" )))
@@ -337,7 +348,7 @@ var _ = Describe("ApplyAggregates", func() {
337348
338349 It ("should return an error about missing aggregate" , func () {
339350 serviceClient := client .ServiceClient (fakeServer )
340- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" , "agg2" , "agg4" })
351+ _ , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg1" , "agg2" , "agg4" })
341352 Expect (err ).To (HaveOccurred ())
342353 Expect (err .Error ()).To (ContainSubstring ("aggregates not found" ))
343354 Expect (err .Error ()).To (ContainSubstring ("agg4" ))
@@ -355,7 +366,7 @@ var _ = Describe("ApplyAggregates", func() {
355366
356367 It ("should return an error listing all missing aggregates" , func () {
357368 serviceClient := client .ServiceClient (fakeServer )
358- err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg4" , "agg5" , "agg6" })
369+ _ , err := ApplyAggregates (ctx , serviceClient , "test-host" , []string {"agg4" , "agg5" , "agg6" })
359370 Expect (err ).To (HaveOccurred ())
360371 Expect (err .Error ()).To (ContainSubstring ("aggregates not found" ))
361372 // Check that all missing aggregates are mentioned in the error
0 commit comments