Skip to content

Commit d173a6d

Browse files
authored
fix(slo test): Don't fail tests if a 404 is seen for a deleted resource (#1940)
1 parent 021346b commit d173a6d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

internal/resources/slo/resource_slo_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package slo_test
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"regexp"
78
"strings"
@@ -275,12 +276,17 @@ func testAdvancedOptionsExists(expectation bool, rn string, slo *slo.SloV00Slo)
275276
}
276277
}
277278

278-
func testAccSloCheckDestroy(slo *slo.SloV00Slo) resource.TestCheckFunc {
279+
func testAccSloCheckDestroy(sloObj *slo.SloV00Slo) resource.TestCheckFunc {
279280
return func(s *terraform.State) error {
280281
client := testutils.Provider.Meta().(*common.Client).SLOClient
281-
req := client.DefaultAPI.V1SloIdGet(context.Background(), slo.Uuid)
282+
req := client.DefaultAPI.V1SloIdGet(context.Background(), sloObj.Uuid)
282283
gotSlo, resp, err := req.Execute()
283284
if err != nil {
285+
var oapiErr slo.GenericOpenAPIError
286+
if errors.As(err, &oapiErr) && strings.Contains(oapiErr.Error(), "404 Not Found") {
287+
return nil
288+
}
289+
284290
return fmt.Errorf("error getting SLO: %s", err)
285291
}
286292

0 commit comments

Comments
 (0)