From 4be21e71dfcaf673016cdea6180225c39b83b063 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 30 Mar 2021 15:02:13 -0400 Subject: [PATCH] tests/provider: Support (helper/schema.Resource).DeleteWithoutTimeout in testAccCheckResourceDisappears (#18398) Reference: https://github.com/hashicorp/terraform-provider-aws/issues/15090 Output from acceptance testing: ``` # Existing Delete --- PASS: TestAccAWSXrayGroup_disappears (15.90s) # Existing DeleteContext --- PASS: TestAccAWSAMPWorkspace_disappears (13.63s) ``` --- aws/provider_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aws/provider_test.go b/aws/provider_test.go index c93a9d5dfb5..fc4bcf762de 100644 --- a/aws/provider_test.go +++ b/aws/provider_test.go @@ -1018,8 +1018,14 @@ func testAccCheckResourceDisappears(provider *schema.Provider, resource *schema. return fmt.Errorf("resource ID missing: %s", resourceName) } - if resource.DeleteContext != nil { - diags := resource.DeleteContext(context.Background(), resource.Data(resourceState.Primary), provider.Meta()) + if resource.DeleteContext != nil || resource.DeleteWithoutTimeout != nil { + var diags diag.Diagnostics + + if resource.DeleteContext != nil { + diags = resource.DeleteContext(context.Background(), resource.Data(resourceState.Primary), provider.Meta()) + } else { + diags = resource.DeleteWithoutTimeout(context.Background(), resource.Data(resourceState.Primary), provider.Meta()) + } for i := range diags { if diags[i].Severity == diag.Error {