diff --git a/aws/data_source_aws_codestarconnections_connection_test.go b/aws/data_source_aws_codestarconnections_connection_test.go index 0e4feb275a8..4c817aa39cb 100644 --- a/aws/data_source_aws_codestarconnections_connection_test.go +++ b/aws/data_source_aws_codestarconnections_connection_test.go @@ -2,7 +2,6 @@ package aws import ( "fmt" - "regexp" "testing" "github.com/aws/aws-sdk-go/service/codestarconnections" @@ -12,20 +11,23 @@ import ( func TestAccDataSourceAwsCodeStarConnectionsConnection_basic(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") - resourceName := "data.aws_codestarconnections_connection.test" + dataSourceName := "data.aws_codestarconnections_connection.test" + resourceName := "aws_codestarconnections_connection.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) }, + ErrorCheck: testAccErrorCheck(t, codestarconnections.EndpointsID), + Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccDataSourceAWSCodeStarConnectionsConnectionConfigBasic(rName), Check: resource.ComposeTestCheckFunc( - testAccMatchResourceAttrRegionalARN(resourceName, "id", "codestar-connections", regexp.MustCompile("connection/.+")), - testAccMatchResourceAttrRegionalARN(resourceName, "arn", "codestar-connections", regexp.MustCompile("connection/.+")), - resource.TestCheckResourceAttr(resourceName, "provider_type", codestarconnections.ProviderTypeBitbucket), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "connection_status", codestarconnections.ConnectionStatusPending), + resource.TestCheckResourceAttrPair(resourceName, "id", dataSourceName, "id"), + resource.TestCheckResourceAttrPair(resourceName, "arn", dataSourceName, "arn"), + resource.TestCheckResourceAttrPair(resourceName, "provider_type", dataSourceName, "provider_type"), + resource.TestCheckResourceAttrPair(resourceName, "name", dataSourceName, "name"), + resource.TestCheckResourceAttrPair(resourceName, "connection_status", dataSourceName, "connection_status"), + resource.TestCheckResourceAttrPair(resourceName, "tags.%", dataSourceName, "tags.%"), ), }, }, @@ -34,18 +36,18 @@ func TestAccDataSourceAwsCodeStarConnectionsConnection_basic(t *testing.T) { func TestAccDataSourceAwsCodeStarConnectionsConnection_tags(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") - resourceName := "data.aws_codestarconnections_connection.test" + dataSourceName := "data.aws_codestarconnections_connection.test" + resourceName := "aws_codestarconnections_connection.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) }, + ErrorCheck: testAccErrorCheck(t, codestarconnections.EndpointsID), + Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccDataSourceAWSCodeStarConnectionsConnectionConfigTags(rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), - resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), - resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + resource.TestCheckResourceAttrPair(resourceName, "tags.%", dataSourceName, "tags.%"), ), }, },