Skip to content

Commit

Permalink
resource - fix various tests (hashicorp#27544)
Browse files Browse the repository at this point in the history
* resource - fix various tests

* Address review

* Lint

* lint

* remove anonymous function from requiresImport test

---------

Co-authored-by: Steph <[email protected]>
  • Loading branch information
mbfrahry and stephybun authored Nov 14, 2024
1 parent 83a0a4b commit 9bab25b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/services/resource/resource_group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
Expand Down Expand Up @@ -193,13 +194,16 @@ func resourceResourceGroupDelete(d *pluginsdk.ResourceData, meta interface{}) er
resourceClient := meta.(*clients.Client).Resource.ResourcesClient
// Resource groups sometimes hold on to resource information after the resources have been deleted. We'll retry this check to account for that eventual consistency.
err = pluginsdk.Retry(10*time.Minute, func() *pluginsdk.RetryError {
results, err := resourceClient.ListByResourceGroupComplete(ctx, id.ResourceGroup, "", "provisioningState", utils.Int32(500))
results, err := resourceClient.ListByResourceGroup(ctx, id.ResourceGroup, "", "provisioningState", utils.Int32(500))
if err != nil {
if response.WasNotFound(results.Response().Response.Response) {
return nil
}
return pluginsdk.NonRetryableError(fmt.Errorf("listing resources in %s: %v", *id, err))
}
nestedResourceIds := make([]string, 0)
for results.NotDone() {
val := results.Value()
for _, value := range results.Values() {
val := value
if val.ID != nil {
nestedResourceIds = append(nestedResourceIds, *val.ID)
}
Expand All @@ -222,6 +226,9 @@ func resourceResourceGroupDelete(d *pluginsdk.ResourceData, meta interface{}) er

deleteFuture, err := client.Delete(ctx, id.ResourceGroup, "")
if err != nil {
if response.WasNotFound(deleteFuture.Response()) {
return nil
}
return fmt.Errorf("deleting %s: %+v", *id, err)
}

Expand Down

0 comments on commit 9bab25b

Please sign in to comment.