Skip to content

Commit 956bb07

Browse files
committed
aws_appconfig_application: add additional test
1 parent 384b016 commit 956bb07

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

internal/service/appconfig/application_data_source_test.go

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/hashicorp/terraform-provider-aws/names"
1515
)
1616

17-
func TestAccAppConfigApplicationDataSource_basic(t *testing.T) {
17+
func TestAccAppConfigApplicationDataSource_basic_name(t *testing.T) {
1818
ctx := acctest.Context(t)
1919
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
2020
dataSourceName := "data.aws_appconfig_application.test"
@@ -30,7 +30,7 @@ func TestAccAppConfigApplicationDataSource_basic(t *testing.T) {
3030
CheckDestroy: testAccCheckApplicationDestroy(ctx),
3131
Steps: []resource.TestStep{
3232
{
33-
Config: testAccApplicationDataSourceConfig_basic(rName),
33+
Config: testAccApplicationDataSourceConfig_name(rName),
3434
Check: resource.ComposeAggregateTestCheckFunc(
3535
testAccCheckApplicationExists(ctx, dataSourceName),
3636
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDescription, resourceName, names.AttrDescription),
@@ -43,15 +43,56 @@ func TestAccAppConfigApplicationDataSource_basic(t *testing.T) {
4343
})
4444
}
4545

46-
func testAccApplicationDataSourceConfig_basic(rName string) string {
46+
func TestAccAppConfigApplicationDataSource_basic_id(t *testing.T) {
47+
ctx := acctest.Context(t)
48+
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
49+
dataSourceName := "data.aws_appconfig_application.test"
50+
resourceName := "aws_appconfig_application.test"
51+
52+
resource.ParallelTest(t, resource.TestCase{
53+
PreCheck: func() {
54+
acctest.PreCheck(ctx, t)
55+
acctest.PreCheckPartitionHasService(t, names.AppConfigEndpointID)
56+
},
57+
ErrorCheck: acctest.ErrorCheck(t, names.AppConfigServiceID),
58+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
59+
CheckDestroy: testAccCheckApplicationDestroy(ctx),
60+
Steps: []resource.TestStep{
61+
{
62+
Config: testAccApplicationDataSourceConfig_id(rName),
63+
Check: resource.ComposeAggregateTestCheckFunc(
64+
testAccCheckApplicationExists(ctx, dataSourceName),
65+
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDescription, resourceName, names.AttrDescription),
66+
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrID, resourceName, names.AttrID),
67+
resource.TestMatchResourceAttr(dataSourceName, names.AttrID, regexache.MustCompile(`[a-z\d]{4,7}`)),
68+
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, resourceName, names.AttrName),
69+
),
70+
},
71+
},
72+
})
73+
}
74+
75+
func testAccApplicationDataSourceConfig_baseConfig(rName string) string {
4776
return fmt.Sprintf(`
4877
resource "aws_appconfig_application" "test" {
4978
name = %[1]q
5079
description = "Example AppConfig Application"
5180
}
81+
`, rName)
82+
}
5283

84+
func testAccApplicationDataSourceConfig_name(rName string) string {
85+
return acctest.ConfigCompose(testAccApplicationDataSourceConfig_baseConfig(rName), `
5386
data "aws_appconfig_application" "test" {
5487
name = aws_appconfig_application.test.name
5588
}
56-
`, rName)
89+
`)
90+
}
91+
92+
func testAccApplicationDataSourceConfig_id(rName string) string {
93+
return acctest.ConfigCompose(testAccApplicationDataSourceConfig_baseConfig(rName), `
94+
data "aws_appconfig_application" "test" {
95+
id = aws_appconfig_application.test.id
96+
}
97+
`)
5798
}

0 commit comments

Comments
 (0)