Add test for additional zones existance
This commit is contained in:
parent
776bc47df3
commit
722fad6d94
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/hashicorp/terraform/helper/acctest"
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccContainerCluster_basic(t *testing.T) {
|
func TestAccContainerCluster_basic(t *testing.T) {
|
||||||
|
@ -37,6 +38,8 @@ func TestAccContainerCluster_withAdditionalZones(t *testing.T) {
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckContainerClusterExists(
|
testAccCheckContainerClusterExists(
|
||||||
"google_container_cluster.with_additional_zones"),
|
"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(`
|
var testAccContainerCluster_basic = fmt.Sprintf(`
|
||||||
resource "google_container_cluster" "primary" {
|
resource "google_container_cluster" "primary" {
|
||||||
name = "cluster-test-%s"
|
name = "cluster-test-%s"
|
||||||
|
|
Loading…
Reference in New Issue