From 88d1f180a73425bcb2a0aeff1cbc638181f78795 Mon Sep 17 00:00:00 2001 From: Kunal Anand Date: Tue, 31 Dec 2019 21:41:09 -0800 Subject: [PATCH] Added workaround to data center resource test for https://github.com/hashicorp/terraform/issues/23635 --- incapsula/resource_data_center_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/incapsula/resource_data_center_test.go b/incapsula/resource_data_center_test.go index 5753d39c..2cb8fffc 100644 --- a/incapsula/resource_data_center_test.go +++ b/incapsula/resource_data_center_test.go @@ -76,6 +76,13 @@ func testAccCheckIncapsulaDataCenterDestroy(state *terraform.State) error { } listDataCenterResponse, _ := client.ListDataCenters(siteID) + + // See comment above - the data center may have already been deleted + // This workaround will be removed in the future + if listDataCenterResponse == nil || listDataCenterResponse.DCs == nil || len(listDataCenterResponse.DCs) == 0 { + return nil + } + for _, dc := range listDataCenterResponse.DCs { if dc.Name == dataCenterName { return fmt.Errorf("Incapsula data center: %s (site_id: %s) still exists", dataCenterName, siteID)