Skip to content

Commit

Permalink
Update CodeStar Connection data source tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shuheiktgw committed Mar 19, 2021
1 parent 615b031 commit 48142f8
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions aws/data_source_aws_codestarconnections_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package aws

import (
"fmt"
"regexp"
"testing"

"github.com/aws/aws-sdk-go/service/codestarconnections"
Expand All @@ -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.%"),
),
},
},
Expand All @@ -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.%"),
),
},
},
Expand Down

0 comments on commit 48142f8

Please sign in to comment.