hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.7k stars 9.07k forks source link

Add ErrorCheck to all tests + semgrep #18175

Closed YakDriver closed 3 years ago

YakDriver commented 3 years ago

Community Note

Description

To facilitate running acceptance tests across partitions, tests should include an ErrorCheck. ErrorCheck will skip tests if they fail for unsupported features rather than code problems. See the Contributing Guide for more information.

Definition of Done

References

bflad commented 3 years ago

tfproviderlint has a new check, XAT001, which can detect this automatically:

...
Error: /home/runner/work/terraform-provider-aws/terraform-provider-aws/aws/data_source_aws_acm_certificate_test.go:38:36: XAT001: missing ErrorCheck
37  
38      resource.ParallelTest(t, resource.TestCase{
39          PreCheck:  func() { testAccPreCheck(t) },
Error: /home/runner/work/terraform-provider-aws/terraform-provider-aws/aws/data_source_aws_acm_certificate_test.go:110:36: XAT001: missing ErrorCheck
109 
110     resource.ParallelTest(t, resource.TestCase{
111         PreCheck:  func() { testAccPreCheck(t) },
Error: /home/runner/work/terraform-provider-aws/terraform-provider-aws/aws/data_source_aws_acm_certificate_test.go:158:36: XAT001: missing ErrorCheck
157 
158     resource.ParallelTest(t, resource.TestCase{
159         PreCheck:  func() { testAccPreCheck(t) },
Error: /home/runner/work/terraform-provider-aws/terraform-provider-aws/aws/data_source_aws_acm_certificate_test.go:197:36: XAT001: missing ErrorCheck
196 
197     resource.ParallelTest(t, resource.TestCase{
198         PreCheck:  func() { testAccPreCheck(t) },
Error: /home/runner/work/terraform-provider-aws/terraform-provider-aws/aws/data_source_aws_acmpca_certificate_authority_test.go:14:36: XAT001: missing ErrorCheck
13  
14      resource.ParallelTest(t, resource.TestCase{
15          PreCheck:  func() { testAccPreCheck(t) },
...

It will remain disabled in our makefile until we are ready.

YakDriver commented 3 years ago

Cool! Thanks. We have a lot of data sources and resources!

ghost commented 3 years ago

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!

ghost commented 3 years ago

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!