Skip to content

Commit

Permalink
Acceptance test import refactor for lambda resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ryndaniels committed Oct 7, 2019
1 parent b297ae3 commit 6576dfd
Show file tree
Hide file tree
Showing 2 changed files with 390 additions and 268 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 6576dfd

Please sign in to comment.