From 3ff66b430f3111454e363ee83be675b6d225a55d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 10 Jul 2014 13:49:09 -0700 Subject: [PATCH] providers/aws: check VPC cidr --- .../providers/aws/resource_aws_vpc_test.go | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_vpc_test.go b/builtin/providers/aws/resource_aws_vpc_test.go index 57c73a020..ef86449a5 100644 --- a/builtin/providers/aws/resource_aws_vpc_test.go +++ b/builtin/providers/aws/resource_aws_vpc_test.go @@ -17,7 +17,10 @@ func TestAccVpc(t *testing.T) { Steps: []resource.TestStep{ resource.TestStep{ Config: testAccVpcConfig, - Check: testAccCheckVpcExists("aws_vpc.foo"), + Check: resource.ComposeTestCheckFunc( + testAccCheckVpcExists("aws_vpc.foo"), + testAccCheckVpcCidr("aws_vpc.foo", "10.1.0.0/16"), + ), }, }, }) @@ -54,6 +57,26 @@ func testAccCheckVpcDestroy(s *terraform.State) error { return nil } +func testAccCheckVpcCidr(n, expected string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + v, ok := rs.Attributes["cidr_block"] + if !ok { + return fmt.Errorf("No cidr_block") + } + + if v != expected { + return fmt.Errorf("Bad cidr: %s", v) + } + + return nil + } +} + func testAccCheckVpcExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.Resources[n]