diff --git a/resource_container_cluster_test.go b/resource_container_cluster_test.go index 3cef09e4..391bd269 100644 --- a/resource_container_cluster_test.go +++ b/resource_container_cluster_test.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "strconv" ) func TestAccContainerCluster_basic(t *testing.T) { @@ -37,6 +38,8 @@ func TestAccContainerCluster_withAdditionalZones(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckContainerClusterExists( "google_container_cluster.with_additional_zones"), + testAccCheckContainerClusterAdditionalZonesExist( + "google_container_cluster.with_additional_zones"), ), }, }, @@ -160,6 +163,29 @@ func testAccCheckContainerClusterExists(n string) resource.TestCheckFunc { } } +func testAccCheckContainerClusterAdditionalZonesExist(n string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + var ( + additionalZonesSize int + err error + ) + + if additionalZonesSize, err = strconv.Atoi(rs.Primary.Attributes["additional_zones.#"]); err != nil { + return err + } + if additionalZonesSize < 2 { + return fmt.Errorf("number of additional zones did not match 2") + } + + return nil + } +} + var testAccContainerCluster_basic = fmt.Sprintf(` resource "google_container_cluster" "primary" { name = "cluster-test-%s"