provider/aws: Fixing the acceptance test for ALB AccessLogs Enabling

toggle

```
% make testacc TEST=./builtin/providers/aws
% TESTARGS='-run=TestAccAWSALB_'
% ✹ ✭
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/10/27 12:04:29 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSALB_ -timeout
120m
=== RUN   TestAccAWSALB_basic
--- PASS: TestAccAWSALB_basic (61.86s)
=== RUN   TestAccAWSALB_generatedName
--- PASS: TestAccAWSALB_generatedName (63.51s)
=== RUN   TestAccAWSALB_namePrefix
--- PASS: TestAccAWSALB_namePrefix (61.93s)
=== RUN   TestAccAWSALB_tags
--- PASS: TestAccAWSALB_tags (95.84s)
=== RUN   TestAccAWSALB_noSecurityGroup
--- PASS: TestAccAWSALB_noSecurityGroup (60.01s)
=== RUN   TestAccAWSALB_accesslogs
--- PASS: TestAccAWSALB_accesslogs (156.99s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws500.162s
```
This commit is contained in:
stack72 2016-10-27 12:12:00 +01:00
parent 54cca9b4fb
commit b3a0145d8c
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
2 changed files with 25 additions and 6 deletions

View File

@ -88,7 +88,7 @@ func resourceAwsAlb() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"enabled": &schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,

View File

@ -213,9 +213,8 @@ func TestAccAWSALB_accesslogs(t *testing.T) {
resource.TestCheckResourceAttrSet("aws_alb.alb_test", "arn"),
),
},
{
Config: testAccAWSALBConfig_accessLogs(albName, bucketName),
Config: testAccAWSALBConfig_accessLogs(true, albName, bucketName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSALBExists("aws_alb.alb_test", &conf),
resource.TestCheckResourceAttr("aws_alb.alb_test", "name", albName),
@ -236,6 +235,26 @@ func TestAccAWSALB_accesslogs(t *testing.T) {
resource.TestCheckResourceAttrSet("aws_alb.alb_test", "arn"),
),
},
{
Config: testAccAWSALBConfig_accessLogs(false, albName, bucketName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSALBExists("aws_alb.alb_test", &conf),
resource.TestCheckResourceAttr("aws_alb.alb_test", "name", albName),
resource.TestCheckResourceAttr("aws_alb.alb_test", "internal", "false"),
resource.TestCheckResourceAttr("aws_alb.alb_test", "subnets.#", "2"),
resource.TestCheckResourceAttr("aws_alb.alb_test", "security_groups.#", "1"),
resource.TestCheckResourceAttr("aws_alb.alb_test", "tags.%", "1"),
resource.TestCheckResourceAttr("aws_alb.alb_test", "tags.TestName", "TestAccAWSALB_basic1"),
resource.TestCheckResourceAttr("aws_alb.alb_test", "enable_deletion_protection", "false"),
resource.TestCheckResourceAttr("aws_alb.alb_test", "idle_timeout", "50"),
resource.TestCheckResourceAttrSet("aws_alb.alb_test", "vpc_id"),
resource.TestCheckResourceAttrSet("aws_alb.alb_test", "zone_id"),
resource.TestCheckResourceAttrSet("aws_alb.alb_test", "dns_name"),
resource.TestCheckResourceAttr("aws_alb.alb_test", "access_logs.#", "1"),
resource.TestCheckResourceAttr("aws_alb.alb_test", "access_logs.0.enabled", "false"),
resource.TestCheckResourceAttrSet("aws_alb.alb_test", "arn"),
),
},
},
})
}
@ -570,7 +589,7 @@ resource "aws_security_group" "alb_test" {
}`, albName)
}
func testAccAWSALBConfig_accessLogs(albName, bucketName string) string {
func testAccAWSALBConfig_accessLogs(enabled bool, albName, bucketName string) string {
return fmt.Sprintf(`resource "aws_alb" "alb_test" {
name = "%s"
internal = false
@ -583,7 +602,7 @@ func testAccAWSALBConfig_accessLogs(albName, bucketName string) string {
access_logs {
bucket = "${aws_s3_bucket.logs.bucket}"
prefix = "${var.bucket_prefix}"
enabled = "${var.enabled}"
enabled = "%t"
}
tags {
@ -678,7 +697,7 @@ resource "aws_security_group" "alb_test" {
tags {
TestName = "TestAccAWSALB_basic"
}
}`, albName, bucketName)
}`, albName, enabled, bucketName)
}
func testAccAWSALBConfig_nosg(albName string) string {