Skip to content

Commit

Permalink
tests/provider: Support (helper/schema.Resource).DeleteWithoutTimeout…
Browse files Browse the repository at this point in the history
… in testAccCheckResourceDisappears (#18398)

Reference: #15090

Output from acceptance testing:

```
# Existing Delete
--- PASS: TestAccAWSXrayGroup_disappears (15.90s)

# Existing DeleteContext
--- PASS: TestAccAWSAMPWorkspace_disappears (13.63s)
```
  • Loading branch information
bflad authored Mar 30, 2021
1 parent 42e6039 commit 4be21e7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aws/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4be21e7

Please sign in to comment.