Skip to content

Commit

Permalink
Merge pull request #10710 from terraform-providers/rfd-3808
Browse files Browse the repository at this point in the history
Use the tf-acc-test prefix for naming API gateways in tests
  • Loading branch information
ryndaniels authored Nov 20, 2019
2 parents 427c75a + 5f14281 commit 8722855
Show file tree
Hide file tree
Showing 11 changed files with 363 additions and 280 deletions.
6 changes: 3 additions & 3 deletions aws/resource_aws_api_gateway_documentation_part_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestAccAWSAPIGatewayDocumentationPart_basic(t *testing.T) {
var conf apigateway.DocumentationPart

rString := acctest.RandString(8)
apiName := fmt.Sprintf("tf_acc_api_doc_part_basic_%s", rString)
apiName := fmt.Sprintf("tf-acc-test_api_doc_part_basic_%s", rString)
properties := `{"description":"Terraform Acceptance Test"}`
uProperties := `{"description":"Terraform Acceptance Test Updated"}`

Expand Down Expand Up @@ -60,7 +60,7 @@ func TestAccAWSAPIGatewayDocumentationPart_method(t *testing.T) {
var conf apigateway.DocumentationPart

rString := acctest.RandString(8)
apiName := fmt.Sprintf("tf_acc_api_doc_part_method_%s", rString)
apiName := fmt.Sprintf("tf-acc-test_api_doc_part_method_%s", rString)
properties := `{"description":"Terraform Acceptance Test"}`
uProperties := `{"description":"Terraform Acceptance Test Updated"}`

Expand Down Expand Up @@ -108,7 +108,7 @@ func TestAccAWSAPIGatewayDocumentationPart_responseHeader(t *testing.T) {
var conf apigateway.DocumentationPart

rString := acctest.RandString(8)
apiName := fmt.Sprintf("tf_acc_api_doc_part_resp_header_%s", rString)
apiName := fmt.Sprintf("tf-acc-test_api_doc_part_resp_header_%s", rString)
properties := `{"description":"Terraform Acceptance Test"}`
uProperties := `{"description":"Terraform Acceptance Test Updated"}`

Expand Down
10 changes: 5 additions & 5 deletions aws/resource_aws_api_gateway_documentation_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func TestAccAWSAPIGatewayDocumentationVersion_basic(t *testing.T) {
var conf apigateway.DocumentationVersion

rString := acctest.RandString(8)
version := fmt.Sprintf("tf_acc_version_%s", rString)
apiName := fmt.Sprintf("tf_acc_api_doc_version_basic_%s", rString)
version := fmt.Sprintf("tf-acc-test_version_%s", rString)
apiName := fmt.Sprintf("tf-acc-test_api_doc_version_basic_%s", rString)

resourceName := "aws_api_gateway_documentation_version.test"

Expand Down Expand Up @@ -46,9 +46,9 @@ func TestAccAWSAPIGatewayDocumentationVersion_allFields(t *testing.T) {
var conf apigateway.DocumentationVersion

rString := acctest.RandString(8)
version := fmt.Sprintf("tf_acc_version_%s", rString)
apiName := fmt.Sprintf("tf_acc_api_doc_version_method_%s", rString)
stageName := fmt.Sprintf("tf_acc_stage_%s", rString)
version := fmt.Sprintf("tf-acc-test_version_%s", rString)
apiName := fmt.Sprintf("tf-acc-test_api_doc_version_method_%s", rString)
stageName := fmt.Sprintf("tf-acc-test_stage_%s", rString)
description := fmt.Sprintf("Tf Acc Test description %s", rString)
uDescription := fmt.Sprintf("Tf Acc Test description updated %s", rString)

Expand Down
43 changes: 25 additions & 18 deletions aws/resource_aws_api_gateway_integration_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,52 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/apigateway"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestAccAWSAPIGatewayIntegrationResponse_basic(t *testing.T) {
var conf apigateway.IntegrationResponse
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10))
resourceName := "aws_api_gateway_integration_response.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayIntegrationResponseDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayIntegrationResponseConfig,
Config: testAccAWSAPIGatewayIntegrationResponseConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationResponseExists("aws_api_gateway_integration_response.test", &conf),
testAccCheckAWSAPIGatewayIntegrationResponseExists(resourceName, &conf),
testAccCheckAWSAPIGatewayIntegrationResponseAttributes(&conf),
resource.TestCheckResourceAttr(
"aws_api_gateway_integration_response.test", "response_templates.application/json", ""),
resourceName, "response_templates.application/json", ""),
resource.TestCheckResourceAttr(
"aws_api_gateway_integration_response.test", "response_templates.application/xml", "#set($inputRoot = $input.path('$'))\n{ }"),
resourceName, "response_templates.application/xml", "#set($inputRoot = $input.path('$'))\n{ }"),
resource.TestCheckResourceAttr(
"aws_api_gateway_integration_response.test", "content_handling", ""),
resourceName, "content_handling", ""),
),
},

{
Config: testAccAWSAPIGatewayIntegrationResponseConfigUpdate,
Config: testAccAWSAPIGatewayIntegrationResponseConfigUpdate(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationResponseExists("aws_api_gateway_integration_response.test", &conf),
testAccCheckAWSAPIGatewayIntegrationResponseExists(resourceName, &conf),
testAccCheckAWSAPIGatewayIntegrationResponseAttributesUpdate(&conf),
resource.TestCheckResourceAttr(
"aws_api_gateway_integration_response.test", "response_templates.application/json", "$input.path('$')"),
resourceName, "response_templates.application/json", "$input.path('$')"),
resource.TestCheckResourceAttr(
"aws_api_gateway_integration_response.test", "response_templates.application/xml", ""),
resourceName, "response_templates.application/xml", ""),
resource.TestCheckResourceAttr(
"aws_api_gateway_integration_response.test", "content_handling", "CONVERT_TO_BINARY"),
resourceName, "content_handling", "CONVERT_TO_BINARY"),
),
},
{
ResourceName: "aws_api_gateway_integration_response.test",
ResourceName: resourceName,
ImportState: true,
ImportStateIdFunc: testAccAWSAPIGatewayIntegrationResponseImportStateIdFunc("aws_api_gateway_integration_response.test"),
ImportStateIdFunc: testAccAWSAPIGatewayIntegrationResponseImportStateIdFunc(resourceName),
ImportStateVerify: true,
},
},
Expand Down Expand Up @@ -174,9 +177,10 @@ func testAccAWSAPIGatewayIntegrationResponseImportStateIdFunc(resourceName strin
}
}

const testAccAWSAPIGatewayIntegrationResponseConfig = `
func testAccAWSAPIGatewayIntegrationResponseConfig(rName string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_rest_api" "test" {
name = "test"
name = "%s"
}
resource "aws_api_gateway_resource" "test" {
Expand Down Expand Up @@ -240,11 +244,13 @@ resource "aws_api_gateway_integration_response" "test" {
"method.response.header.Content-Type" = "integration.response.body.type"
}
}
`
`, rName)
}

const testAccAWSAPIGatewayIntegrationResponseConfigUpdate = `
func testAccAWSAPIGatewayIntegrationResponseConfigUpdate(rName string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_rest_api" "test" {
name = "test"
name = "%s"
}
resource "aws_api_gateway_resource" "test" {
Expand Down Expand Up @@ -306,4 +312,5 @@ resource "aws_api_gateway_integration_response" "test" {
content_handling = "CONVERT_TO_BINARY"
}
`
`, rName)
}
81 changes: 48 additions & 33 deletions aws/resource_aws_api_gateway_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import (

func TestAccAWSAPIGatewayIntegration_basic(t *testing.T) {
var conf apigateway.Integration
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(7))

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayIntegrationDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayIntegrationConfig,
Config: testAccAWSAPIGatewayIntegrationConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationExists("aws_api_gateway_integration.test", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "type", "HTTP"),
Expand All @@ -42,7 +43,7 @@ func TestAccAWSAPIGatewayIntegration_basic(t *testing.T) {
},

{
Config: testAccAWSAPIGatewayIntegrationConfigUpdate,
Config: testAccAWSAPIGatewayIntegrationConfigUpdate(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationExists("aws_api_gateway_integration.test", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "type", "HTTP"),
Expand All @@ -62,7 +63,7 @@ func TestAccAWSAPIGatewayIntegration_basic(t *testing.T) {
},

{
Config: testAccAWSAPIGatewayIntegrationConfigUpdateURI,
Config: testAccAWSAPIGatewayIntegrationConfigUpdateURI(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationExists("aws_api_gateway_integration.test", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "type", "HTTP"),
Expand All @@ -82,7 +83,7 @@ func TestAccAWSAPIGatewayIntegration_basic(t *testing.T) {
},

{
Config: testAccAWSAPIGatewayIntegrationConfigUpdateNoTemplates,
Config: testAccAWSAPIGatewayIntegrationConfigUpdateNoTemplates(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationExists("aws_api_gateway_integration.test", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "type", "HTTP"),
Expand All @@ -98,7 +99,7 @@ func TestAccAWSAPIGatewayIntegration_basic(t *testing.T) {
},

{
Config: testAccAWSAPIGatewayIntegrationConfig,
Config: testAccAWSAPIGatewayIntegrationConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationExists("aws_api_gateway_integration.test", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "type", "HTTP"),
Expand Down Expand Up @@ -127,14 +128,15 @@ func TestAccAWSAPIGatewayIntegration_basic(t *testing.T) {

func TestAccAWSAPIGatewayIntegration_contentHandling(t *testing.T) {
var conf apigateway.Integration
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(7))

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayIntegrationDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayIntegrationConfig,
Config: testAccAWSAPIGatewayIntegrationConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationExists("aws_api_gateway_integration.test", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "type", "HTTP"),
Expand All @@ -153,7 +155,7 @@ func TestAccAWSAPIGatewayIntegration_contentHandling(t *testing.T) {
},

{
Config: testAccAWSAPIGatewayIntegrationConfigUpdateContentHandling,
Config: testAccAWSAPIGatewayIntegrationConfigUpdateContentHandling(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationExists("aws_api_gateway_integration.test", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "type", "HTTP"),
Expand All @@ -170,9 +172,8 @@ func TestAccAWSAPIGatewayIntegration_contentHandling(t *testing.T) {
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "request_templates.application/xml", "#set($inputRoot = $input.path('$'))\n{ }"),
),
},

{
Config: testAccAWSAPIGatewayIntegrationConfigRemoveContentHandling,
Config: testAccAWSAPIGatewayIntegrationConfigRemoveContentHandling(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationExists("aws_api_gateway_integration.test", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "type", "HTTP"),
Expand Down Expand Up @@ -201,14 +202,15 @@ func TestAccAWSAPIGatewayIntegration_contentHandling(t *testing.T) {

func TestAccAWSAPIGatewayIntegration_cache_key_parameters(t *testing.T) {
var conf apigateway.Integration
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(7))

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayIntegrationDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayIntegrationConfigCacheKeyParameters,
Config: testAccAWSAPIGatewayIntegrationConfigCacheKeyParameters(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayIntegrationExists("aws_api_gateway_integration.test", &conf),
resource.TestCheckResourceAttr("aws_api_gateway_integration.test", "type", "HTTP"),
Expand Down Expand Up @@ -241,8 +243,7 @@ func TestAccAWSAPIGatewayIntegration_cache_key_parameters(t *testing.T) {

func TestAccAWSAPIGatewayIntegration_integrationType(t *testing.T) {
var conf apigateway.Integration

rName := fmt.Sprintf("tf-acctest-apigw-int-%s", acctest.RandString(7))
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(7))

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -356,9 +357,10 @@ func testAccAWSAPIGatewayIntegrationImportStateIdFunc(resourceName string) resou
}
}

const testAccAWSAPIGatewayIntegrationConfig = `
func testAccAWSAPIGatewayIntegrationConfig(rName string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_rest_api" "test" {
name = "test"
name = "%s"
}
resource "aws_api_gateway_resource" "test" {
Expand Down Expand Up @@ -399,11 +401,13 @@ resource "aws_api_gateway_integration" "test" {
passthrough_behavior = "WHEN_NO_MATCH"
content_handling = "CONVERT_TO_TEXT"
}
`
`, rName)
}

const testAccAWSAPIGatewayIntegrationConfigUpdate = `
func testAccAWSAPIGatewayIntegrationConfigUpdate(rName string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_rest_api" "test" {
name = "test"
name = "%s"
}
resource "aws_api_gateway_resource" "test" {
Expand Down Expand Up @@ -445,11 +449,13 @@ resource "aws_api_gateway_integration" "test" {
content_handling = "CONVERT_TO_TEXT"
timeout_milliseconds = 2000
}
`
`, rName)
}

const testAccAWSAPIGatewayIntegrationConfigUpdateURI = `
func testAccAWSAPIGatewayIntegrationConfigUpdateURI(rName string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_rest_api" "test" {
name = "test"
name = "%s"
}
resource "aws_api_gateway_resource" "test" {
Expand Down Expand Up @@ -491,11 +497,13 @@ resource "aws_api_gateway_integration" "test" {
content_handling = "CONVERT_TO_TEXT"
timeout_milliseconds = 2000
}
`
`, rName)
}

const testAccAWSAPIGatewayIntegrationConfigUpdateContentHandling = `
func testAccAWSAPIGatewayIntegrationConfigUpdateContentHandling(rName string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_rest_api" "test" {
name = "test"
name = "%s"
}
resource "aws_api_gateway_resource" "test" {
Expand Down Expand Up @@ -537,11 +545,13 @@ resource "aws_api_gateway_integration" "test" {
content_handling = "CONVERT_TO_BINARY"
timeout_milliseconds = 2000
}
`
`, rName)
}

const testAccAWSAPIGatewayIntegrationConfigRemoveContentHandling = `
func testAccAWSAPIGatewayIntegrationConfigRemoveContentHandling(rName string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_rest_api" "test" {
name = "test"
name = "%s"
}
resource "aws_api_gateway_resource" "test" {
Expand Down Expand Up @@ -582,11 +592,13 @@ resource "aws_api_gateway_integration" "test" {
passthrough_behavior = "WHEN_NO_MATCH"
timeout_milliseconds = 2000
}
`
`, rName)
}

const testAccAWSAPIGatewayIntegrationConfigUpdateNoTemplates = `
func testAccAWSAPIGatewayIntegrationConfigUpdateNoTemplates(rName string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_rest_api" "test" {
name = "test"
name = "%s"
}
resource "aws_api_gateway_resource" "test" {
Expand Down Expand Up @@ -618,11 +630,13 @@ resource "aws_api_gateway_integration" "test" {
content_handling = "CONVERT_TO_TEXT"
timeout_milliseconds = 2000
}
`
`, rName)
}

const testAccAWSAPIGatewayIntegrationConfigCacheKeyParameters = `
func testAccAWSAPIGatewayIntegrationConfigCacheKeyParameters(rName string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_rest_api" "test" {
name = "test"
name = "%s"
}
resource "aws_api_gateway_resource" "test" {
Expand Down Expand Up @@ -672,7 +686,8 @@ resource "aws_api_gateway_integration" "test" {
content_handling = "CONVERT_TO_TEXT"
timeout_milliseconds = 2000
}
`
`, rName)
}

func testAccAWSAPIGatewayIntegrationConfig_IntegrationTypeBase(rName string) string {
return fmt.Sprintf(`
Expand Down
Loading

0 comments on commit 8722855

Please sign in to comment.