Skip to content

Commit

Permalink
Test cleanup 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasZalewski committed Aug 1, 2024
1 parent 034ed5d commit 17ce18a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
1 change: 1 addition & 0 deletions internal/service/datazone/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ var (
IsResourceMissing = isResourceMissing
ResourceProject = newResourceProject
ResourceGlossary = newResourceGlossary
FindGlossaryByID = findGlossaryByID
)
31 changes: 2 additions & 29 deletions internal/service/datazone/glossary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/datazone"
awstypes "github.com/aws/aws-sdk-go-v2/service/datazone/types"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
Expand All @@ -22,7 +21,6 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/create"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
tfdatazone "github.com/hashicorp/terraform-provider-aws/internal/service/datazone"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
"github.com/hashicorp/terraform-provider-aws/names"
)

Expand Down Expand Up @@ -175,7 +173,7 @@ func testAccCheckGlossaryDestroy(ctx context.Context) resource.TestCheckFunc {
if rs.Type != "aws_datazone_glossary" {
continue
}
_, err := findGlossaryByID(ctx, conn, rs.Primary.ID, rs.Primary.Attributes["domain_identifier"])
_, err := tfdatazone.FindGlossaryByID(ctx, conn, rs.Primary.ID, rs.Primary.Attributes["domain_identifier"])
if errs.IsA[*awstypes.ResourceNotFoundException](err) || errs.IsA[*awstypes.AccessDeniedException](err) {
return nil
}
Expand Down Expand Up @@ -204,7 +202,7 @@ func testAccCheckGlossaryExists(ctx context.Context, name string, glossary *data
return create.Error(names.DataZone, create.ErrActionCheckingExistence, tfdatazone.ResNameProject, name, errors.New("domain identifier not set"))
}
conn := acctest.Provider.Meta().(*conns.AWSClient).DataZoneClient(ctx)
resp, err := findGlossaryByID(ctx, conn, rs.Primary.ID, rs.Primary.Attributes["domain_identifier"])
resp, err := tfdatazone.FindGlossaryByID(ctx, conn, rs.Primary.ID, rs.Primary.Attributes["domain_identifier"])

if err != nil {
return create.Error(names.DataZone, create.ErrActionCheckingExistence, tfdatazone.ResNameGlossary, rs.Primary.ID, err)
Expand All @@ -216,31 +214,6 @@ func testAccCheckGlossaryExists(ctx context.Context, name string, glossary *data
}
}

func findGlossaryByID(ctx context.Context, conn *datazone.Client, id string, domain_id string) (*datazone.GetGlossaryOutput, error) {
in := &datazone.GetGlossaryInput{
Identifier: aws.String(id),
DomainIdentifier: aws.String(domain_id),
}

out, err := conn.GetGlossary(ctx, in)
if err != nil {
if errs.IsA[*awstypes.ResourceNotFoundException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: in,
}
}

return nil, err
}

if out == nil {
return nil, tfresource.NewEmptyResultError(in)
}

return out, nil
}

func testAccCheckGlossaryNotRecreated(before, after *datazone.GetGlossaryOutput) resource.TestCheckFunc {
return func(s *terraform.State) error {
if before, after := aws.ToString(before.Id), aws.ToString(after.Id); before != after {
Expand Down

0 comments on commit 17ce18a

Please sign in to comment.