providers/aws: check VPC cidr

This commit is contained in:
Mitchell Hashimoto 2014-07-10 13:49:09 -07:00
parent e992d62717
commit 3ff66b430f
1 changed files with 24 additions and 1 deletions

View File

@ -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]