Skip to content

Commit

Permalink
tests/provider: Fix and enable tfproviderlint AT012 for mismatched ac…
Browse files Browse the repository at this point in the history
…ceptance test prefixes within a single file

Reference: #18377

This selection process was just choosing the most prominent naming convention within the files, not making any assertions about which is better.

The ELB "Update" tests were just configuration update versions of the non-"Update" tests so consolidated to just the updating tests. The EB import test was the same as the basic test so moved the import step to the basic test as is customary.

Output from acceptance testing for modified tests:

```
--- PASS: TestAccAWSBeanstalkApp_basic (17.01s)
```
  • Loading branch information
bflad committed Apr 1, 2021
1 parent 345d924 commit 00f3da4
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 138 deletions.
1 change: 0 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ awsproviderlint:
-AWSAT006=false \
-AWSV001=false \
-AT010=false \
-AT012=false \
-R001=false \
-R010=false \
-R018=false \
Expand Down
2 changes: 1 addition & 1 deletion aws/data_source_aws_directory_service_directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestAccDataSourceAwsDirectoryServiceDirectory_MicrosoftAD(t *testing.T) {
})
}

func TestAccDataSourceAWSDirectoryServiceDirectory_connector(t *testing.T) {
func TestAccDataSourceAwsDirectoryServiceDirectory_connector(t *testing.T) {
resourceName := "aws_directory_service_directory.connector"
dataSourceName := "data.aws_directory_service_directory.test-ad-connector"

Expand Down
2 changes: 1 addition & 1 deletion aws/data_source_aws_launch_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestAccAWSLaunchConfigurationDataSource_ebsNoDevice(t *testing.T) {
})
}

func TestAccLaunchConfigurationDataSource_metadataOptions(t *testing.T) {
func TestAccAWSLaunchConfigurationDataSource_metadataOptions(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
dataSourceName := "data.aws_launch_configuration.test"
resourceName := "aws_launch_configuration.test"
Expand Down
2 changes: 1 addition & 1 deletion aws/data_source_aws_lb_target_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccDataSourceAWSALBTargetGroup_basic(t *testing.T) {
func TestAccDataSourceAWSLBTargetGroup_basic(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceNameArn := "data.aws_lb_target_group.alb_tg_test_with_arn"
resourceName := "data.aws_lb_target_group.alb_tg_test_with_name"
Expand Down
2 changes: 1 addition & 1 deletion aws/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ func testSweepSkipResourceError(err error) bool {
return tfawserr.ErrCodeContains(err, "AccessDenied")
}

func TestAccProvider_DefaultTags_EmptyConfigurationBlock(t *testing.T) {
func TestAccAWSProvider_DefaultTags_EmptyConfigurationBlock(t *testing.T) {
var providers []*schema.Provider

resource.ParallelTest(t, resource.TestCase{
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_db_option_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestAccAWSDBOptionGroup_generatedName(t *testing.T) {
})
}

func TestAccAWSDBOptionGroupConfig_OptionGroupDescription(t *testing.T) {
func TestAccAWSDBOptionGroup_OptionGroupDescription(t *testing.T) {
var optionGroup1 rds.OptionGroup
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_db_option_group.test"
Expand Down
40 changes: 7 additions & 33 deletions aws/resource_aws_elastic_beanstalk_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,10 @@ func testSweepElasticBeanstalkApplications(region string) error {
return errors
}

func TestAccAWSElasticBeanstalkApplication_basic(t *testing.T) {
resourceName := "aws_elastic_beanstalk_application.tftest"
config := fmt.Sprintf("tf-test-name-%d", acctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, elasticbeanstalk.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckBeanstalkAppDestroy,
Steps: []resource.TestStep{
{
Config: testAccBeanstalkAppImportConfig(config),
},

{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccBeanstalkAppImportConfig(name string) string {
return fmt.Sprintf(`
resource "aws_elastic_beanstalk_application" "tftest" {
name = "%s"
description = "tf-test-desc"
}
`, name)
}

func TestAccAWSBeanstalkApp_basic(t *testing.T) {
var app elasticbeanstalk.ApplicationDescription
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_elastic_beanstalk_application.tftest"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -107,9 +76,14 @@ func TestAccAWSBeanstalkApp_basic(t *testing.T) {
{
Config: testAccBeanstalkAppConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckBeanstalkAppExists("aws_elastic_beanstalk_application.tftest", &app),
testAccCheckBeanstalkAppExists(resourceName, &app),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down
97 changes: 0 additions & 97 deletions aws/resource_aws_elb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,33 +614,6 @@ func TestAccAWSELB_listener(t *testing.T) {
}

func TestAccAWSELB_HealthCheck(t *testing.T) {
var conf elb.LoadBalancerDescription
resourceName := "aws_elb.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, elb.EndpointsID),
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSELBDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSELBConfigHealthCheck,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSELBExists(resourceName, &conf),
testAccCheckAWSELBAttributesHealthCheck(&conf),
resource.TestCheckResourceAttr(resourceName, "health_check.0.healthy_threshold", "5"),
resource.TestCheckResourceAttr(resourceName, "health_check.0.unhealthy_threshold", "5"),
resource.TestCheckResourceAttr(resourceName, "health_check.0.target", "HTTP:8000/"),
resource.TestCheckResourceAttr(resourceName, "health_check.0.timeout", "30"),
resource.TestCheckResourceAttr(resourceName, "health_check.0.interval", "60"),
),
},
},
})
}

func TestAccAWSELBUpdate_HealthCheck(t *testing.T) {
resourceName := "aws_elb.test"

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -668,28 +641,6 @@ func TestAccAWSELBUpdate_HealthCheck(t *testing.T) {
}

func TestAccAWSELB_Timeout(t *testing.T) {
var conf elb.LoadBalancerDescription
resourceName := "aws_elb.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, elb.EndpointsID),
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSELBDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSELBConfigIdleTimeout,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSELBExists(resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "idle_timeout", "200"),
),
},
},
})
}

func TestAccAWSELBUpdate_Timeout(t *testing.T) {
resourceName := "aws_elb.test"

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -718,29 +669,6 @@ func TestAccAWSELBUpdate_Timeout(t *testing.T) {
func TestAccAWSELB_ConnectionDraining(t *testing.T) {
resourceName := "aws_elb.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, elb.EndpointsID),
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSELBDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSELBConfigConnectionDraining,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
resourceName, "connection_draining", "true",
),
resource.TestCheckResourceAttr(resourceName, "connection_draining_timeout", "400"),
),
},
},
})
}

func TestAccAWSELBUpdate_ConnectionDraining(t *testing.T) {
resourceName := "aws_elb.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, elb.EndpointsID),
Expand Down Expand Up @@ -1075,31 +1003,6 @@ func testAccCheckAWSELBAttributes(conf *elb.LoadBalancerDescription) resource.Te
}
}

func testAccCheckAWSELBAttributesHealthCheck(conf *elb.LoadBalancerDescription) resource.TestCheckFunc {
return func(s *terraform.State) error {
check := &elb.HealthCheck{
Timeout: aws.Int64(int64(30)),
UnhealthyThreshold: aws.Int64(int64(5)),
HealthyThreshold: aws.Int64(int64(5)),
Interval: aws.Int64(int64(60)),
Target: aws.String("HTTP:8000/"),
}

if !reflect.DeepEqual(conf.HealthCheck, check) {
return fmt.Errorf(
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
conf.HealthCheck,
check)
}

if *conf.DNSName == "" {
return fmt.Errorf("empty dns_name")
}

return nil
}
}

func testAccCheckAWSELBExists(n string, res *elb.LoadBalancerDescription) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_opsworks_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func TestAccAWSOpsworksStack_CustomCookbooks_SetPrivateProperties(t *testing.T)
// Tests the addition of regional endpoints and supporting the classic link used
// to create Stack's prior to v0.9.0.
// See https://github.com/hashicorp/terraform/issues/12842
func TestAccAWSOpsWorksStack_classicEndpoints(t *testing.T) {
func TestAccAWSOpsworksStack_classicEndpoints(t *testing.T) {
stackName := fmt.Sprintf("tf-opsworks-acc-%d", acctest.RandInt())
resourceName := "aws_opsworks_stack.main"
rInt := acctest.RandInt()
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_s3_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func TestAccAWSS3Bucket_ignoreTags(t *testing.T) {
})
}

func TestAccAWSS3MultiBucket_withTags(t *testing.T) {
func TestAccAWSS3Bucket_withTags(t *testing.T) {
rInt := acctest.RandInt()
resourceName := "aws_s3_bucket.bucket1"

Expand Down

0 comments on commit 00f3da4

Please sign in to comment.