-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CodeStar Connection data source #18129
Add CodeStar Connection data source #18129
Conversation
7e4ae2f
to
dbcccdf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor testing updates, otherwise this is looking really good, thank you @shuheiktgw 🎉
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) }, | ||
Providers: testAccProviders, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are currently in the process of adding ErrorCheck
to each of the acceptance tests. Reference: #18175
Can you please add this here? Thank you!
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, |
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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For data source testing, we prefer using resource.TestCheckResourceAttrPair()
where possible to simplify it. 👍 Reference: https://github.com/hashicorp/terraform-provider-aws/blob/main/docs/contributing/running-and-writing-acceptance-tests.md#data-source-acceptance-testing
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(dataSourceName, "arn", resourceName, "arn"), | |
resource.TestCheckResourceAttrPair(dataSourceName, "connection_status", resourceName, "connection_status"), | |
resource.TestCheckResourceAttrPair(dataSourceName, "id", resourceName, "id"), | |
resource.TestCheckResourceAttrPair(dataSourceName, "provider_type", resourceName, "provider_type"), | |
resource.TestCheckResourceAttrPair(dataSourceName, "name", resourceName, "name"), | |
resource.TestCheckResourceAttrPair(dataSourceName, "tags.%", resourceName, "tags.%"), |
|
||
func TestAccDataSourceAwsCodeStarConnectionsConnection_basic(t *testing.T) { | ||
rName := acctest.RandomWithPrefix("tf-acc-test") | ||
resourceName := "data.aws_codestarconnections_connection.test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it can be referenced below 😄
resourceName := "data.aws_codestarconnections_connection.test" | |
dataSourceName := "data.aws_codestarconnections_connection.test" | |
resourceName := "aws_codestarconnections_connection.test" |
|
||
func TestAccDataSourceAwsCodeStarConnectionsConnection_tags(t *testing.T) { | ||
rName := acctest.RandomWithPrefix("tf-acc-test") | ||
resourceName := "data.aws_codestarconnections_connection.test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly:
resourceName := "data.aws_codestarconnections_connection.test" | |
dataSourceName := "data.aws_codestarconnections_connection.test" | |
resourceName := "aws_codestarconnections_connection.test" |
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) }, | ||
Providers: testAccProviders, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly:
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, |
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), | ||
resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), | ||
resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), | |
resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), | |
resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), | |
resource.TestCheckResourceAttrPair(dataSourceName, "tags.%", resourceName, "tags.%"), |
adcc7ed
to
48142f8
Compare
Thanks, @bflad! Updated the tests, so would you review the PR again?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 🚀 (Forgot to mention adding a changelog entry before 😅 will do so on merge)
Output from acceptance testing:
--- PASS: TestAccDataSourceAwsCodeStarConnectionsConnection_basic (19.66s)
--- PASS: TestAccDataSourceAwsCodeStarConnectionsConnection_tags (19.69s)
--- PASS: TestAccAWSCodeStarConnectionsConnection_disappears (12.08s)
--- PASS: TestAccAWSCodeStarConnectionsConnection_Basic (16.27s)
--- PASS: TestAccAWSCodeStarConnectionsConnection_Tags (35.69s)
Thank you for your review, @bflad! |
This has been released in version 3.34.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Relates #15453
Output from acceptance testing:
Added CodeStar Connection data source. Thank you for your review!