@@ -298,6 +298,49 @@ var _ = Describe("Placement API", func() {
298298 })
299299 })
300300
301+ Context ("when deleting consumer allocations fails" , func () {
302+ BeforeEach (func () {
303+ fakeServer .Mux .HandleFunc (providerAllocsURL , func (w http.ResponseWriter , r * http.Request ) {
304+ w .Header ().Set ("Content-Type" , "application/json" )
305+ w .WriteHeader (http .StatusOK )
306+ fmt .Fprint (w , `{"allocations": {"consumer-1": {}}}` )
307+ })
308+
309+ fakeServer .Mux .HandleFunc ("/allocations/consumer-1" , func (w http.ResponseWriter , r * http.Request ) {
310+ switch r .Method {
311+ case http .MethodGet :
312+ // Consumer has no allocations of its own — proceed to delete
313+ w .Header ().Set ("Content-Type" , "application/json" )
314+ w .WriteHeader (http .StatusOK )
315+ fmt .Fprint (w , `{"allocations": {}, "consumer_generation": 0}` )
316+ case http .MethodDelete :
317+ // Deletion fails
318+ w .WriteHeader (http .StatusInternalServerError )
319+ fmt .Fprint (w , `{"error": "Internal Server Error"}` )
320+ }
321+ })
322+
323+ // The provider delete succeeds, so that it cannot accidentally surface
324+ // the error for us — only the consumer allocation delete error should be returned.
325+ fakeServer .Mux .HandleFunc (deleteProviderURL , func (w http.ResponseWriter , r * http.Request ) {
326+ w .WriteHeader (http .StatusNoContent )
327+ })
328+ })
329+
330+ It ("should return an error when consumer allocation deletion fails" , func () {
331+ provider := & resourceproviders.ResourceProvider {
332+ UUID : providerUUID ,
333+ Name : "test-provider" ,
334+ }
335+
336+ err := CleanupResourceProvider (ctx , client .ServiceClient (fakeServer ), provider )
337+ // Bug: deleteConsumerAllocations return value is discarded, so this
338+ // error is silently swallowed and the function proceeds to delete the
339+ // provider and returns nil instead of the deletion error.
340+ Expect (err ).To (HaveOccurred ())
341+ })
342+ })
343+
301344 Context ("when deleting provider fails" , func () {
302345 BeforeEach (func () {
303346 fakeServer .Mux .HandleFunc (providerAllocsURL , func (w http.ResponseWriter , r * http.Request ) {
0 commit comments