@@ -14,7 +14,7 @@ import (
14
14
"github.com/hashicorp/terraform-provider-aws/names"
15
15
)
16
16
17
- func TestAccAppConfigApplicationDataSource_basic (t * testing.T ) {
17
+ func TestAccAppConfigApplicationDataSource_basic_name (t * testing.T ) {
18
18
ctx := acctest .Context (t )
19
19
rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
20
20
dataSourceName := "data.aws_appconfig_application.test"
@@ -30,7 +30,7 @@ func TestAccAppConfigApplicationDataSource_basic(t *testing.T) {
30
30
CheckDestroy : testAccCheckApplicationDestroy (ctx ),
31
31
Steps : []resource.TestStep {
32
32
{
33
- Config : testAccApplicationDataSourceConfig_basic (rName ),
33
+ Config : testAccApplicationDataSourceConfig_name (rName ),
34
34
Check : resource .ComposeAggregateTestCheckFunc (
35
35
testAccCheckApplicationExists (ctx , dataSourceName ),
36
36
resource .TestCheckResourceAttrPair (dataSourceName , names .AttrDescription , resourceName , names .AttrDescription ),
@@ -43,15 +43,56 @@ func TestAccAppConfigApplicationDataSource_basic(t *testing.T) {
43
43
})
44
44
}
45
45
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 {
47
76
return fmt .Sprintf (`
48
77
resource "aws_appconfig_application" "test" {
49
78
name = %[1]q
50
79
description = "Example AppConfig Application"
51
80
}
81
+ ` , rName )
82
+ }
52
83
84
+ func testAccApplicationDataSourceConfig_name (rName string ) string {
85
+ return acctest .ConfigCompose (testAccApplicationDataSourceConfig_baseConfig (rName ), `
53
86
data "aws_appconfig_application" "test" {
54
87
name = aws_appconfig_application.test.name
55
88
}
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
+ ` )
57
98
}
0 commit comments