Skip to content

Commit

Permalink
Add actual backend verification for stack existence
Browse files Browse the repository at this point in the history
  • Loading branch information
htahir1 committed Oct 27, 2024
1 parent 2fa2871 commit fc340ec
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions internal/provider/resource_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func testAccCheckStackDestroy(s *terraform.State) error {
// Add this new function
func testAccCheckStackExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
// Retrieve the resource by name from state
rs, ok := s.RootModule().Resources[resourceName]
if !ok {
return fmt.Errorf("Not found: %s", resourceName)
Expand All @@ -57,15 +56,12 @@ func testAccCheckStackExists(resourceName string) resource.TestCheckFunc {
return fmt.Errorf("No Stack ID is set")
}

// Add code here to check if the stack exists in your system
// This typically involves making an API call to your backend

// For example:
// client := testAccProvider.Meta().(*YourClientType)
// _, err := client.GetStack(rs.Primary.ID)
// if err != nil {
// return fmt.Errorf("Error retrieving stack: %s", err)
// }
// Add actual backend verification
client := testAccProvider.Meta().(*Client)
_, err := client.GetStack(rs.Primary.ID)
if err != nil {
return fmt.Errorf("error fetching stack with ID %s: %s", rs.Primary.ID, err)
}

return nil
}
Expand Down

0 comments on commit fc340ec

Please sign in to comment.