Skip to content
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

import test lintignores for API gateway resources #10618

Merged
merged 1 commit into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions aws/resource_aws_api_gateway_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,13 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestAccAWSAPIGatewayAccount_importBasic(t *testing.T) {
resourceName := "aws_api_gateway_account.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayAccountDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayAccountConfig_empty,
},

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

func TestAccAWSAPIGatewayAccount_basic(t *testing.T) {
var conf apigateway.Account

rInt := acctest.RandInt()
firstName := fmt.Sprintf("tf_acc_api_gateway_cloudwatch_%d", rInt)
secondName := fmt.Sprintf("tf_acc_api_gateway_cloudwatch_modified_%d", rInt)

resourceName := "aws_api_gateway_account.test"
expectedRoleArn_first := regexp.MustCompile(":role/" + firstName + "$")
expectedRoleArn_second := regexp.MustCompile(":role/" + secondName + "$")

Expand All @@ -50,23 +29,29 @@ func TestAccAWSAPIGatewayAccount_basic(t *testing.T) {
{
Config: testAccAWSAPIGatewayAccountConfig_updated(firstName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayAccountExists("aws_api_gateway_account.test", &conf),
testAccCheckAWSAPIGatewayAccountExists(resourceName, &conf),
testAccCheckAWSAPIGatewayAccountCloudwatchRoleArn(&conf, expectedRoleArn_first),
resource.TestMatchResourceAttr("aws_api_gateway_account.test", "cloudwatch_role_arn", expectedRoleArn_first),
resource.TestMatchResourceAttr(resourceName, "cloudwatch_role_arn", expectedRoleArn_first),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"cloudwatch_role_arn"},
},
{
Config: testAccAWSAPIGatewayAccountConfig_updated2(secondName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayAccountExists("aws_api_gateway_account.test", &conf),
testAccCheckAWSAPIGatewayAccountExists(resourceName, &conf),
testAccCheckAWSAPIGatewayAccountCloudwatchRoleArn(&conf, expectedRoleArn_second),
resource.TestMatchResourceAttr("aws_api_gateway_account.test", "cloudwatch_role_arn", expectedRoleArn_second),
resource.TestMatchResourceAttr(resourceName, "cloudwatch_role_arn", expectedRoleArn_second),
),
},
{
Config: testAccAWSAPIGatewayAccountConfig_empty,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayAccountExists("aws_api_gateway_account.test", &conf),
testAccCheckAWSAPIGatewayAccountExists(resourceName, &conf),
testAccCheckAWSAPIGatewayAccountCloudwatchRoleArn(&conf, expectedRoleArn_second),
),
},
Expand Down
39 changes: 12 additions & 27 deletions aws/resource_aws_api_gateway_client_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

func TestAccAWSAPIGatewayClientCertificate_basic(t *testing.T) {
var conf apigateway.ClientCertificate
resourceName := "aws_api_gateway_client_certificate.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -22,38 +23,22 @@ func TestAccAWSAPIGatewayClientCertificate_basic(t *testing.T) {
{
Config: testAccAWSAPIGatewayClientCertificateConfig_basic,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayClientCertificateExists("aws_api_gateway_client_certificate.cow", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_client_certificate.cow", "description", "Hello from TF acceptance test"),
testAccCheckAWSAPIGatewayClientCertificateExists(resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "description", "Hello from TF acceptance test"),
),
},
{
Config: testAccAWSAPIGatewayClientCertificateConfig_basic_updated,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayClientCertificateExists("aws_api_gateway_client_certificate.cow", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_client_certificate.cow", "description", "Hello from TF acceptance test - updated"),
),
},
},
})
}

func TestAccAWSAPIGatewayClientCertificate_importBasic(t *testing.T) {
resourceName := "aws_api_gateway_client_certificate.cow"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayClientCertificateDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayClientCertificateConfig_basic,
},

{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSAPIGatewayClientCertificateConfig_basic_updated,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayClientCertificateExists(resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "description", "Hello from TF acceptance test - updated"),
),
},
},
})
}
Expand Down Expand Up @@ -116,13 +101,13 @@ func testAccCheckAWSAPIGatewayClientCertificateDestroy(s *terraform.State) error
}

const testAccAWSAPIGatewayClientCertificateConfig_basic = `
resource "aws_api_gateway_client_certificate" "cow" {
resource "aws_api_gateway_client_certificate" "test" {
description = "Hello from TF acceptance test"
}
`

const testAccAWSAPIGatewayClientCertificateConfig_basic_updated = `
resource "aws_api_gateway_client_certificate" "cow" {
resource "aws_api_gateway_client_certificate" "test" {
description = "Hello from TF acceptance test - updated"
}
`
48 changes: 15 additions & 33 deletions aws/resource_aws_api_gateway_documentation_part_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func TestAccAWSAPIGatewayDocumentationPart_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSAPIGatewayDocumentationPartConfig(apiName, strconv.Quote(uProperties)),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -78,6 +83,11 @@ func TestAccAWSAPIGatewayDocumentationPart_method(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSAPIGatewayDocumentationPartMethodConfig(apiName, strconv.Quote(uProperties)),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -123,6 +133,11 @@ func TestAccAWSAPIGatewayDocumentationPart_responseHeader(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSAPIGatewayDocumentationPartResponseHeaderConfig(apiName, strconv.Quote(uProperties)),
Check: resource.ComposeTestCheckFunc(
Expand All @@ -141,39 +156,6 @@ func TestAccAWSAPIGatewayDocumentationPart_responseHeader(t *testing.T) {
})
}

func TestAccAWSAPIGatewayDocumentationPart_importBasic(t *testing.T) {
var conf apigateway.DocumentationPart

rString := acctest.RandString(8)
apiName := fmt.Sprintf("tf_acc_api_doc_part_import_%s", rString)
properties := `{"description":"Terraform Acceptance Test"}`

resourceName := "aws_api_gateway_documentation_part.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayDocumentationPartDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayDocumentationPartConfig(apiName, strconv.Quote(properties)),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayDocumentationPartExists(resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "location.#", "1"),
resource.TestCheckResourceAttr(resourceName, "location.0.type", "API"),
resource.TestCheckResourceAttr(resourceName, "properties", properties),
resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccCheckAWSAPIGatewayDocumentationPartExists(n string, res *apigateway.DocumentationPart) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down
60 changes: 10 additions & 50 deletions aws/resource_aws_api_gateway_documentation_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func TestAccAWSAPIGatewayDocumentationVersion_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down Expand Up @@ -63,6 +68,11 @@ func TestAccAWSAPIGatewayDocumentationVersion_allFields(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSAPIGatewayDocumentationVersionAllFieldsConfig(version, apiName, stageName, uDescription),
Check: resource.ComposeTestCheckFunc(
Expand All @@ -76,56 +86,6 @@ func TestAccAWSAPIGatewayDocumentationVersion_allFields(t *testing.T) {
})
}

func TestAccAWSAPIGatewayDocumentationVersion_importBasic(t *testing.T) {
rString := acctest.RandString(8)
version := fmt.Sprintf("tf_acc_version_import_%s", rString)
apiName := fmt.Sprintf("tf_acc_api_doc_version_import_%s", rString)

resourceName := "aws_api_gateway_documentation_version.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayDocumentationVersionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayDocumentationVersionBasicConfig(version, apiName),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSAPIGatewayDocumentationVersion_importAllFields(t *testing.T) {
rString := acctest.RandString(8)
version := fmt.Sprintf("tf_acc_version_import_af_%s", rString)
apiName := fmt.Sprintf("tf_acc_api_doc_version_import_af_%s", rString)
stageName := fmt.Sprintf("tf_acc_stage_%s", rString)
description := fmt.Sprintf("Tf Acc Test description %s", rString)

resourceName := "aws_api_gateway_documentation_version.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayDocumentationVersionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayDocumentationVersionAllFieldsConfig(version, apiName, stageName, description),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccCheckAWSAPIGatewayDocumentationVersionExists(n string, res *apigateway.DocumentationVersion) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down
Loading