Skip to content

Commit

Permalink
fixup diff after rebasing master
Browse files Browse the repository at this point in the history
  • Loading branch information
mackenziestarr committed Aug 7, 2019
1 parent 87aacde commit 4fdeabe
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
7 changes: 5 additions & 2 deletions google/resource_bigtable_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,11 @@ func resourceBigtableInstanceClusterReorderTypeList(diff *schema.ResourceDiff, m
old_count, new_count := diff.GetChange("cluster.#")

// simulate Required:true, MinItems:1, MaxItems:4 for "cluster"
if new_count.(int) < 1 || new_count.(int) > 4 {
return fmt.Errorf("Error applying diff. Resource definition should contain at least one cluster block but no more than four, got %d blocks", new_count.(int))
if new_count.(int) < 1 {
return fmt.Errorf("config is invalid: Too few cluster blocks: Should have at least 1 \"cluster\" block")
}
if new_count.(int) > 4 {
return fmt.Errorf("config is invalid: Too many cluster blocks: No more than 4 \"cluster\" blocks are allowed")
}

if old_count.(int) != new_count.(int) {
Expand Down
40 changes: 32 additions & 8 deletions google/resource_bigtable_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func TestAccBigtableInstance_basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckBigtableInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccBigtableInstance_invalid(instanceName),
ExpectError: regexp.MustCompile("config is invalid: Too few cluster blocks: Should have at least 1 \"cluster\" block"),
},
{
Config: testAccBigtableInstance(instanceName, 3),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -173,6 +177,14 @@ resource "google_bigtable_instance" "instance" {
`, instanceName, instanceName, numNodes)
}

func testAccBigtableInstance_invalid(instanceName string) string {
return fmt.Sprintf(`
resource "google_bigtable_instance" "instance" {
name = "%s"
}
`, instanceName)
}

func testAccBigtableInstance_cluster(instanceName string, numNodes int) string {
return fmt.Sprintf(`
resource "google_bigtable_instance" "instance" {
Expand Down Expand Up @@ -202,7 +214,7 @@ resource "google_bigtable_instance" "instance" {
storage_type = "HDD"
}
}
`, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes)
`, instanceName, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes)
}

func testAccBigtableInstance_clusterMax(instanceName string) string {
Expand All @@ -224,7 +236,19 @@ resource "google_bigtable_instance" "instance" {
cluster {
cluster_id = "%s-c"
zone = "us-central1-c"
num_nodes = %d
num_nodes = 3
storage_type = "HDD"
}
cluster {
cluster_id = "%s-d"
zone = "us-central1-f"
num_nodes = 3
storage_type = "HDD"
}
cluster {
cluster_id = "%s-e"
zone = "us-east1-a"
num_nodes = 3
storage_type = "HDD"
}
}
Expand All @@ -236,9 +260,9 @@ func testAccBigtableInstance_cluster_reordered(instanceName string, numNodes int
resource "google_bigtable_instance" "instance" {
name = "%s"
cluster {
num_nodes = %d
cluster_id = "%s-b"
cluster_id = "%s-c"
zone = "us-central1-c"
num_nodes = %d
storage_type = "HDD"
}
cluster {
Expand All @@ -248,19 +272,19 @@ resource "google_bigtable_instance" "instance" {
storage_type = "HDD"
}
cluster {
zone = "us-central1-b"
cluster_id = "%s-a"
zone = "us-central1-a"
num_nodes = %d
storage_type = "HDD"
}
cluster {
cluster_id = "%s-e"
zone = "us-east1-a"
cluster_id = "%s-b"
zone = "us-central1-b"
num_nodes = %d
storage_type = "HDD"
}
}
`, instanceName, numNodes, instanceName, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes, instanceName)
`, instanceName, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes)
}

func testAccBigtableInstance_development(instanceName string) string {
Expand Down

0 comments on commit 4fdeabe

Please sign in to comment.