Skip to content

Commit

Permalink
[r|d]/aws_memorydb_user(test): adjust iam authentication_mode tests
Browse files Browse the repository at this point in the history
Simplifies the configuration by removing tags (tested in other
configurations) and applies consistent naming to both tests and
associated configurations.

```console
% make testacc PKG=memorydb TESTS="TestAccMemoryDBUser|TestAccMemoryDBUserDataSource"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/memorydb/... -v -count 1 -parallel 20 -run='TestAccMemoryDBUser|TestAccMemoryDBUserDataSource'  -timeout 360m

--- PASS: TestAccMemoryDBUser_tags (45.96s)
--- PASS: TestAccMemoryDBUserDataSource_authenticationModeIAM (49.38s)
--- PASS: TestAccMemoryDBUserDataSource_basic (49.38s)
--- PASS: TestAccMemoryDBUser_basic (52.16s)
--- PASS: TestAccMemoryDBUser_authenticationModeIAM (52.20s)
--- PASS: TestAccMemoryDBUser_disappears (58.02s)
--- PASS: TestAccMemoryDBUser_update_accessString (105.60s)
--- PASS: TestAccMemoryDBUser_update_passwords (173.49s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/memorydb   178.422s
```
  • Loading branch information
jar-b committed Apr 25, 2024
1 parent 1790717 commit bc3f21b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
12 changes: 3 additions & 9 deletions internal/service/memorydb/user_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestAccMemoryDBUserDataSource_basic(t *testing.T) {
})
}

func TestAccMemoryDBUserDataSource_iam(t *testing.T) {
func TestAccMemoryDBUserDataSource_authenticationModeIAM(t *testing.T) {
ctx := acctest.Context(t)
rName := "tf-test-" + sdkacctest.RandString(8)
resourceName := "aws_memorydb_user.test"
Expand All @@ -53,15 +53,13 @@ func TestAccMemoryDBUserDataSource_iam(t *testing.T) {
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccUserDataSourceConfig_iam(rName),
Config: testAccUserDataSourceConfig_authenticationModeIAM(rName),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "access_string", resourceName, "access_string"),
resource.TestCheckResourceAttrPair(dataSourceName, "arn", resourceName, "arn"),
resource.TestCheckResourceAttrPair(dataSourceName, "authentication_mode.0.type", resourceName, "authentication_mode.0.type"),
resource.TestCheckResourceAttrPair(dataSourceName, "authentication_mode.0.password_count", resourceName, "authentication_mode.0.password_count"),
resource.TestCheckResourceAttrPair(dataSourceName, "minimum_engine_version", resourceName, "minimum_engine_version"),
resource.TestCheckResourceAttr(dataSourceName, "tags.%", "1"),
resource.TestCheckResourceAttrPair(dataSourceName, "tags.Test", resourceName, "tags.Test"),
resource.TestCheckResourceAttrPair(dataSourceName, "user_name", resourceName, "user_name"),
),
},
Expand Down Expand Up @@ -91,7 +89,7 @@ data "aws_memorydb_user" "test" {
`, rName)
}

func testAccUserDataSourceConfig_iam(rName string) string {
func testAccUserDataSourceConfig_authenticationModeIAM(rName string) string {
return fmt.Sprintf(`
resource "aws_memorydb_user" "test" {
access_string = "on ~* &* +@all"
Expand All @@ -100,10 +98,6 @@ resource "aws_memorydb_user" "test" {
authentication_mode {
type = "iam"
}
tags = {
Test = "test"
}
}
data "aws_memorydb_user" "test" {
Expand Down
12 changes: 3 additions & 9 deletions internal/service/memorydb/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestAccMemoryDBUser_basic(t *testing.T) {
})
}

func TestAccMemoryDBUser_iam_auth_mode(t *testing.T) {
func TestAccMemoryDBUser_authenticationModeIAM(t *testing.T) {
ctx := acctest.Context(t)
rName := "tf-test-" + sdkacctest.RandString(8)
resourceName := "aws_memorydb_user.test"
Expand All @@ -67,7 +67,7 @@ func TestAccMemoryDBUser_iam_auth_mode(t *testing.T) {
CheckDestroy: testAccCheckUserDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccUserConfigWithIAMAuthMode_basic(rName),
Config: testAccUserConfig_authenticationModeIAM(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckUserExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "access_string", "on ~* &* +@all"),
Expand All @@ -76,8 +76,6 @@ func TestAccMemoryDBUser_iam_auth_mode(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "authentication_mode.0.password_count", "0"),
resource.TestCheckResourceAttrSet(resourceName, "minimum_engine_version"),
resource.TestCheckResourceAttr(resourceName, "user_name", rName),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(resourceName, "tags.Test", "test"),
),
},
{
Expand Down Expand Up @@ -313,7 +311,7 @@ resource "aws_memorydb_user" "test" {
`, rName)
}

func testAccUserConfigWithIAMAuthMode_basic(rName string) string {
func testAccUserConfig_authenticationModeIAM(rName string) string {
return fmt.Sprintf(`
resource "aws_memorydb_user" "test" {
access_string = "on ~* &* +@all"
Expand All @@ -322,10 +320,6 @@ resource "aws_memorydb_user" "test" {
authentication_mode {
type = "iam"
}
tags = {
Test = "test"
}
}
`, rName)
}
Expand Down

0 comments on commit bc3f21b

Please sign in to comment.