Skip to content

Commit

Permalink
Merge pull request #14956 from terraform-providers/td-config-acctests
Browse files Browse the repository at this point in the history
tech-debt/config: update TypeSet check and remove custom disappears funcs
  • Loading branch information
anGie44 authored Sep 2, 2020
2 parents ea99e96 + 0d4675a commit aef4d84
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 43 deletions.
2 changes: 1 addition & 1 deletion aws/resource_aws_config_config_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func testAccConfigConfigRule_customlambda(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "source.0.owner", "CUSTOM_LAMBDA"),
resource.TestCheckResourceAttrPair(resourceName, "source.0.source_identifier", "aws_lambda_function.f", "arn"),
resource.TestCheckResourceAttr(resourceName, "source.0.source_detail.#", "1"),
tfawsresource.TestCheckTypeSetElemNestedAttrs(resourceName, "source.0.source_detail", map[string]string{
tfawsresource.TestCheckTypeSetElemNestedAttrs(resourceName, "source.0.source_detail.*", map[string]string{
"event_source": "aws.config",
"message_type": "ConfigurationSnapshotDeliveryCompleted",
"maximum_execution_frequency": "",
Expand Down
22 changes: 1 addition & 21 deletions aws/resource_aws_config_organization_custom_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"fmt"
"regexp"
"testing"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/configservice"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down Expand Up @@ -65,7 +63,7 @@ func testAccConfigOrganizationCustomRule_disappears(t *testing.T) {
Config: testAccConfigOrganizationCustomRuleConfigTriggerTypes1(rName, "ConfigurationItemChangeNotification"),
Check: resource.ComposeTestCheckFunc(
testAccCheckConfigOrganizationCustomRuleExists(resourceName, &rule),
testAccCheckConfigOrganizationCustomRuleDisappears(&rule),
testAccCheckResourceDisappears(testAccProvider, resourceAwsConfigOrganizationCustomRule(), resourceName),
),
ExpectNonEmptyPlan: true,
},
Expand Down Expand Up @@ -475,24 +473,6 @@ func testAccCheckConfigOrganizationCustomRuleDestroy(s *terraform.State) error {
return nil
}

func testAccCheckConfigOrganizationCustomRuleDisappears(rule *configservice.OrganizationConfigRule) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).configconn

input := &configservice.DeleteOrganizationConfigRuleInput{
OrganizationConfigRuleName: rule.OrganizationConfigRuleName,
}

_, err := conn.DeleteOrganizationConfigRule(input)

if err != nil {
return err
}

return configWaitForOrganizationRuleStatusDeleteSuccessful(conn, aws.StringValue(rule.OrganizationConfigRuleName), 5*time.Minute)
}
}

func testAccConfigOrganizationCustomRuleConfigBase(rName string) string {
return fmt.Sprintf(`
data "aws_partition" "current" {
Expand Down
22 changes: 1 addition & 21 deletions aws/resource_aws_config_organization_managed_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"fmt"
"regexp"
"testing"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/configservice"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down Expand Up @@ -63,7 +61,7 @@ func testAccConfigOrganizationManagedRule_disappears(t *testing.T) {
Config: testAccConfigOrganizationManagedRuleConfigRuleIdentifier(rName, "IAM_PASSWORD_POLICY"),
Check: resource.ComposeTestCheckFunc(
testAccCheckConfigOrganizationManagedRuleExists(resourceName, &rule),
testAccCheckConfigOrganizationManagedRuleDisappears(&rule),
testAccCheckResourceDisappears(testAccProvider, resourceAwsConfigOrganizationManagedRule(), resourceName),
),
ExpectNonEmptyPlan: true,
},
Expand Down Expand Up @@ -438,24 +436,6 @@ func testAccCheckConfigOrganizationManagedRuleDestroy(s *terraform.State) error
return nil
}

func testAccCheckConfigOrganizationManagedRuleDisappears(rule *configservice.OrganizationConfigRule) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).configconn

input := &configservice.DeleteOrganizationConfigRuleInput{
OrganizationConfigRuleName: rule.OrganizationConfigRuleName,
}

_, err := conn.DeleteOrganizationConfigRule(input)

if err != nil {
return err
}

return configWaitForOrganizationRuleStatusDeleteSuccessful(conn, aws.StringValue(rule.OrganizationConfigRuleName), 5*time.Minute)
}
}

func testAccConfigOrganizationManagedRuleConfigBase(rName string) string {
return fmt.Sprintf(`
data "aws_partition" "current" {
Expand Down

0 comments on commit aef4d84

Please sign in to comment.