Skip to content

Commit

Permalink
[ignore] Addition of capability to testcheckdestroy function which ch…
Browse files Browse the repository at this point in the history
…ecks destruction of resources
  • Loading branch information
shrsr committed Apr 26, 2024
1 parent 07abd47 commit e75c0a8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,19 @@ func testCheckResourceAttr(resourceName, attribute, value1 string) resource.Test

func testCheckResourceDestroy(s *terraform.State) error {
aciClient := getACIClientTest(nil)
for _, rs := range s.RootModule().Resources {
_, err := aciClient.Get(rs.Primary.ID)
if err != nil {
if strings.Contains(err.Error(), "Error retrieving Object: Object may not exist") {
continue
} else {
return fmt.Errorf("error checking if resource '%s' with ID '%s' still exists: %s", rs.Type, rs.Primary.ID, err)

for name, rs := range s.RootModule().Resources {
if !strings.HasPrefix(name, "data.") {
_, err := aciClient.Get(rs.Primary.ID)
if err != nil {
if strings.Contains(err.Error(), "Error retrieving Object: Object may not exist") {
continue
} else {
return fmt.Errorf("error checking if resource '%s' with ID '%s' still exists: %s", rs.Type, rs.Primary.ID, err)
}
}
return fmt.Errorf("terraform destroy was unsuccessful. The resource '%s' with ID '%s' still exists", rs.Type, rs.Primary.ID)
}
return fmt.Errorf("terraform destroy was unsuccessful. The resource '%s' with ID '%s' still exists", rs.Type, rs.Primary.ID)
}
return nil
}
Expand Down

0 comments on commit e75c0a8

Please sign in to comment.