Skip to content

Commit

Permalink
fix error check when validating that a port was deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Jul 2, 2024
1 parent e942795 commit 3ecc54f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/resources/metal/port/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package port_test
import (
"context"
"fmt"
"net/http"
"regexp"
"slices"
"testing"

"github.com/equinix/terraform-provider-equinix/internal/acceptance"
Expand Down Expand Up @@ -372,9 +374,11 @@ func testAccMetalPortDestroyed(s *terraform.State) error {
}
}
for _, pid := range port_ids {
p, _, err := client.PortsApi.FindPortById(context.Background(), pid).Execute()
p, resp, err := client.PortsApi.FindPortById(context.Background(), pid).Execute()
if err != nil {
return fmt.Errorf("Error getting port %s during destroy check: %v", pid, err)
if resp != nil && slices.Contains([]int{http.StatusNotFound, http.StatusForbidden}, resp.StatusCode) {
return fmt.Errorf("Error getting port %s during destroy check: %v", pid, err)
}
}
err = port.ProperlyDestroyed(p)
if err != nil {
Expand Down

0 comments on commit 3ecc54f

Please sign in to comment.