Skip to content

Commit

Permalink
provider/aws: Cleanup tests - have 1 checkFunc per attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Radek Simko committed Feb 25, 2016
1 parent 6f37e27 commit 7c9412c
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions builtin/providers/aws/resource_aws_lambda_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func TestAccAWSLambdaFunction_basic(t *testing.T) {
Config: testAccAWSLambdaConfigBasic,
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_test", "example_lambda_name", &conf),
testAccCheckAWSLambdaAttributes(&conf),
testAccCheckAwsLambdaFunctionName(&conf, "example_lambda_name"),
testAccCheckAwsLambdaFunctionArnHasSuffix(&conf, ":example_lambda_name"),
),
},
},
Expand All @@ -46,7 +47,8 @@ func TestAccAWSLambdaFunction_VPC(t *testing.T) {
Config: testAccAWSLambdaConfigWithVPC,
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_test", "example_lambda_name", &conf),
testAccCheckAWSLambdaAttributes(&conf),
testAccCheckAwsLambdaFunctionName(&conf, "example_lambda_name"),
testAccCheckAwsLambdaFunctionArnHasSuffix(&conf, ":example_lambda_name"),
),
},
},
Expand Down Expand Up @@ -230,22 +232,6 @@ func testAccCheckAwsLambdaSourceCodeHash(function *lambda.GetFunctionOutput, exp
}
}

func testAccCheckAWSLambdaAttributes(function *lambda.GetFunctionOutput) resource.TestCheckFunc {
return func(s *terraform.State) error {
c := function.Configuration
const expectedName = "example_lambda_name"
if *c.FunctionName != expectedName {
return fmt.Errorf("Expected function name %s, got %s", expectedName, *c.FunctionName)
}

if *c.FunctionArn == "" {
return fmt.Errorf("Could not read Lambda Function's ARN")
}

return nil
}
}

func testAccCreateZipFromFiles(files map[string]string, zipFile *os.File) error {
zipFile.Truncate(0)
zipFile.Seek(0, 0)
Expand Down

0 comments on commit 7c9412c

Please sign in to comment.