From f238f0c51fd74031c9abc62dcf01d81db75f1378 Mon Sep 17 00:00:00 2001 From: eggsbenjamin Date: Mon, 2 Jul 2018 16:15:26 +0100 Subject: [PATCH 1/2] re-added tests --- aws/resource_aws_lambda_alias_test.go | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/aws/resource_aws_lambda_alias_test.go b/aws/resource_aws_lambda_alias_test.go index 683bf0b7317..0fc5b9fa2a3 100644 --- a/aws/resource_aws_lambda_alias_test.go +++ b/aws/resource_aws_lambda_alias_test.go @@ -32,6 +32,7 @@ func TestAccAWSLambdaAlias_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckAwsLambdaAliasExists("aws_lambda_alias.lambda_alias_test", &conf), testAccCheckAwsLambdaAttributes(&conf), + testAccCheckAwsLambdaAliasRoutingConfigDoesNotExist(&conf), resource.TestMatchResourceAttr("aws_lambda_alias.lambda_alias_test", "arn", regexp.MustCompile(`^arn:aws:lambda:[a-z]+-[a-z]+-[0-9]+:\d{12}:function:`+funcName+`:`+aliasName+`$`)), ), @@ -78,6 +79,35 @@ func TestAccAWSLambdaAlias_nameupdate(t *testing.T) { }) } +func TestAccAWSLambdaAlias_routingconfig(t *testing.T) { + var conf lambda.AliasConfiguration + + rString := acctest.RandString(8) + roleName := fmt.Sprintf("tf_acc_role_lambda_alias_basic_%s", rString) + policyName := fmt.Sprintf("tf_acc_policy_lambda_alias_basic_%s", rString) + attachmentName := fmt.Sprintf("tf_acc_attachment_%s", rString) + funcName := fmt.Sprintf("tf_acc_lambda_func_alias_basic_%s", rString) + aliasName := fmt.Sprintf("tf_acc_lambda_alias_basic_%s", rString) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAwsLambdaAliasDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAwsLambdaAliasConfigWithRoutingConfig(roleName, policyName, attachmentName, funcName, aliasName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsLambdaAliasExists("aws_lambda_alias.lambda_alias_test", &conf), + testAccCheckAwsLambdaAttributes(&conf), + testAccCheckAwsLambdaAliasRoutingConfigExists(&conf), + resource.TestMatchResourceAttr("aws_lambda_alias.lambda_alias_test", "arn", + regexp.MustCompile(`^arn:aws:lambda:[a-z]+-[a-z]+-[0-9]+:\d{12}:function:`+funcName+`:`+aliasName+`$`)), + ), + }, + }, + }) +} + func testAccCheckAwsLambdaAliasDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).lambdaconn From 33f00e5fca6e874468ede05d27f1bb91b6cfd709 Mon Sep 17 00:00:00 2001 From: eggsbenjamin Date: Mon, 2 Jul 2018 23:28:05 +0100 Subject: [PATCH 2/2] re-added old acceptance tests --- aws/resource_aws_lambda_alias.go | 4 ++-- aws/resource_aws_lambda_alias_test.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_lambda_alias.go b/aws/resource_aws_lambda_alias.go index 09d2416a4e9..110ea8cf4ea 100644 --- a/aws/resource_aws_lambda_alias.go +++ b/aws/resource_aws_lambda_alias.go @@ -190,8 +190,8 @@ func expandLambdaAliasRoutingConfiguration(l []interface{}) *lambda.AliasRouting m := l[0].(map[string]interface{}) - if _, ok := m["additional_version_weights"]; ok { - aliasRoutingConfiguration.AdditionalVersionWeights = expandFloat64Map(m) + if v, ok := m["additional_version_weights"]; ok { + aliasRoutingConfiguration.AdditionalVersionWeights = expandFloat64Map(v.(map[string]interface{})) } return aliasRoutingConfiguration diff --git a/aws/resource_aws_lambda_alias_test.go b/aws/resource_aws_lambda_alias_test.go index 0fc5b9fa2a3..6a6113700d4 100644 --- a/aws/resource_aws_lambda_alias_test.go +++ b/aws/resource_aws_lambda_alias_test.go @@ -94,6 +94,15 @@ func TestAccAWSLambdaAlias_routingconfig(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAwsLambdaAliasDestroy, Steps: []resource.TestStep{ + { + Config: testAccAwsLambdaAliasConfig(roleName, policyName, attachmentName, funcName, aliasName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsLambdaAliasExists("aws_lambda_alias.lambda_alias_test", &conf), + testAccCheckAwsLambdaAttributes(&conf), + resource.TestMatchResourceAttr("aws_lambda_alias.lambda_alias_test", "arn", + regexp.MustCompile(`^arn:aws:lambda:[a-z]+-[a-z]+-[0-9]+:\d{12}:function:`+funcName+`:`+aliasName+`$`)), + ), + }, { Config: testAccAwsLambdaAliasConfigWithRoutingConfig(roleName, policyName, attachmentName, funcName, aliasName), Check: resource.ComposeTestCheckFunc( @@ -104,6 +113,16 @@ func TestAccAWSLambdaAlias_routingconfig(t *testing.T) { regexp.MustCompile(`^arn:aws:lambda:[a-z]+-[a-z]+-[0-9]+:\d{12}:function:`+funcName+`:`+aliasName+`$`)), ), }, + { + Config: testAccAwsLambdaAliasConfig(roleName, policyName, attachmentName, funcName, aliasName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsLambdaAliasExists("aws_lambda_alias.lambda_alias_test", &conf), + testAccCheckAwsLambdaAttributes(&conf), + testAccCheckAwsLambdaAliasRoutingConfigDoesNotExist(&conf), + resource.TestMatchResourceAttr("aws_lambda_alias.lambda_alias_test", "arn", + regexp.MustCompile(`^arn:aws:lambda:[a-z]+-[a-z]+-[0-9]+:\d{12}:function:`+funcName+`:`+aliasName+`$`)), + ), + }, }, }) }