Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(slo test): Don't fail tests if a 404 is seen for a deleted resource #1940

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions internal/resources/slo/resource_slo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package slo_test

import (
"context"
"errors"
"fmt"
"regexp"
"strings"
Expand Down Expand Up @@ -275,12 +276,17 @@ func testAdvancedOptionsExists(expectation bool, rn string, slo *slo.SloV00Slo)
}
}

func testAccSloCheckDestroy(slo *slo.SloV00Slo) resource.TestCheckFunc {
func testAccSloCheckDestroy(sloObj *slo.SloV00Slo) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testutils.Provider.Meta().(*common.Client).SLOClient
req := client.DefaultAPI.V1SloIdGet(context.Background(), slo.Uuid)
req := client.DefaultAPI.V1SloIdGet(context.Background(), sloObj.Uuid)
gotSlo, resp, err := req.Execute()
if err != nil {
var oapiErr slo.GenericOpenAPIError
if errors.As(err, &oapiErr) && strings.Contains(oapiErr.Error(), "404 Not Found") {
return nil
}

return fmt.Errorf("error getting SLO: %s", err)
}

Expand Down
Loading