Skip to content

Commit

Permalink
Merge pull request #10027 from terraform-providers/rfd-at002-lambda
Browse files Browse the repository at this point in the history
Acceptance import test refactor for lambda
  • Loading branch information
ryndaniels authored Oct 9, 2019
2 parents 1647a5b + 5530094 commit 0f81f1b
Show file tree
Hide file tree
Showing 2 changed files with 387 additions and 271 deletions.
42 changes: 18 additions & 24 deletions aws/resource_aws_lambda_event_source_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ func TestAccAWSLambdaEventSourceMapping_kinesis_basic(t *testing.T) {
testAccCheckAWSLambdaEventSourceMappingAttributes(&conf),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"enabled", "starting_position"},
},
{
Config: testAccAWSLambdaEventSourceMappingConfigUpdate_kinesis(roleName, policyName, attName, streamName, funcName, uFuncName),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -84,6 +90,12 @@ func TestAccAWSLambdaEventSourceMapping_kinesis_removeBatchSize(t *testing.T) {
testAccCheckAWSLambdaEventSourceMappingAttributes(&conf),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"enabled", "starting_position"},
},
{
Config: testAccAWSLambdaEventSourceMappingConfigUpdate_kinesis_removeBatchSize(roleName, policyName, attName, streamName, funcName, uFuncName),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -125,6 +137,12 @@ func TestAccAWSLambdaEventSourceMapping_sqs_basic(t *testing.T) {
"starting_position"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"enabled", "starting_position"},
},
{
Config: testAccAWSLambdaEventSourceMappingConfigUpdate_sqs(roleName, policyName, attName, streamName, funcName, uFuncName),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -167,30 +185,6 @@ func TestAccAWSLambdaEventSourceMapping_sqs_withFunctionName(t *testing.T) {
resource.TestCheckNoResourceAttr(resourceName, "starting_position"),
),
},
},
})
}

func TestAccAWSLambdaEventSourceMapping_kinesis_import(t *testing.T) {
resourceName := "aws_lambda_event_source_mapping.lambda_event_source_mapping_test"

rString := acctest.RandString(8)
roleName := fmt.Sprintf("tf_acc_role_lambda_esm_import_%s", rString)
policyName := fmt.Sprintf("tf_acc_policy_lambda_esm_import_%s", rString)
attName := fmt.Sprintf("tf_acc_att_lambda_esm_import_%s", rString)
streamName := fmt.Sprintf("tf_acc_stream_lambda_esm_import_%s", rString)
funcName := fmt.Sprintf("tf_acc_lambda_esm_import_%s", rString)
uFuncName := fmt.Sprintf("tf_acc_lambda_esm_import_updated_%s", rString)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLambdaEventSourceMappingDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSLambdaEventSourceMappingConfig_kinesis(roleName, policyName, attName, streamName, funcName, uFuncName),
},

{
ResourceName: resourceName,
ImportState: true,
Expand Down
Loading

0 comments on commit 0f81f1b

Please sign in to comment.