Skip to content

Commit

Permalink
tidy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonaj committed Aug 15, 2024
1 parent cabf1c8 commit 6a4e5b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion internal/service/datazone/form_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func findFormTypeByID(ctx context.Context, conn *datazone.Client, domainId strin
}

out, err := conn.GetFormType(ctx, in)
if errs.IsA[*awstypes.ResourceNotFoundException](err) {
if errs.IsA[*awstypes.ResourceNotFoundException](err) || errs.IsA[*awstypes.AccessDeniedException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: in,
Expand Down
32 changes: 11 additions & 21 deletions internal/service/datazone/form_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ import (
"strings"
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/datazone"
"github.com/aws/aws-sdk-go-v2/service/datazone/types"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"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 All @@ -31,8 +29,7 @@ func TestAccDataZoneFormType_basic(t *testing.T) {
}

var formtype datazone.GetFormTypeOutput
dName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
pName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resourceName := "aws_datazone_form_type.test"
domainName := "aws_datazone_domain.test"
Expand All @@ -48,7 +45,7 @@ func TestAccDataZoneFormType_basic(t *testing.T) {
CheckDestroy: testAccCheckFormTypeDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccFormTypeConfig_basic(pName, dName),
Config: testAccFormTypeConfig_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckFormTypeExists(ctx, resourceName, &formtype),
resource.TestCheckResourceAttrSet(resourceName, names.AttrCreatedAt),
Expand Down Expand Up @@ -81,8 +78,7 @@ func TestAccDataZoneFormType_disappears(t *testing.T) {
}

var formtype datazone.GetFormTypeOutput
dName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
pName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resourceName := "aws_datazone_form_type.test"

Expand All @@ -97,7 +93,7 @@ func TestAccDataZoneFormType_disappears(t *testing.T) {
CheckDestroy: testAccCheckFormTypeDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccFormTypeConfig_basic(pName, dName),
Config: testAccFormTypeConfig_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckFormTypeExists(ctx, resourceName, &formtype),
acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfdatazone.ResourceFormType, resourceName),
Expand All @@ -117,16 +113,11 @@ func testAccCheckFormTypeDestroy(ctx context.Context) resource.TestCheckFunc {
continue
}

in := &datazone.GetFormTypeInput{
DomainIdentifier: aws.String(rs.Primary.Attributes["domain_identifier"]),
FormTypeIdentifier: aws.String(rs.Primary.Attributes[names.AttrName]),
Revision: aws.String(rs.Primary.Attributes["revision"]),
_, err := tfdatazone.FindFormTypeByID(ctx, conn, rs.Primary.Attributes["domain_identifier"], rs.Primary.Attributes[names.AttrName], rs.Primary.Attributes["revision"])
if tfresource.NotFound(err) {
continue
}

_, err := conn.GetFormType(ctx, in)
if errs.IsA[*types.ResourceNotFoundException](err) || errs.IsA[*types.AccessDeniedException](err) {
return nil
}
if err != nil {
return create.Error(names.DataZone, create.ErrActionCheckingDestroyed, tfdatazone.ResNameFormType, rs.Primary.ID, err)
}
Expand Down Expand Up @@ -173,9 +164,8 @@ func testAccAuthorizerImportStateUserProfileFunc(resourceName string) resource.I
}
}

func testAccFormTypeConfig_basic(pName, dName string) string {
return acctest.ConfigCompose(testAccProjectConfig_basic(pName, dName), (`
func testAccFormTypeConfig_basic(rName string) string {
return acctest.ConfigCompose(testAccProjectConfig_basic(rName, rName), `
resource "aws_datazone_form_type" "test" {
description = "desc"
name = "SageMakerModelFormType"
Expand All @@ -198,5 +188,5 @@ resource "aws_datazone_form_type" "test" {
EOF
}
}
`))
`)
}

0 comments on commit 6a4e5b7

Please sign in to comment.