From 13e9e6f51dc11b3d1963df0cd96a7a94f56a320c Mon Sep 17 00:00:00 2001 From: Dan Carley Date: Thu, 7 May 2015 08:13:06 +0100 Subject: [PATCH] provider/gce: Test updates to http_health_check By first creating a very simple resource that mostly uses the default values and then changing the two thresholds from their computed defaults. This currently fails with the following error and will be fixed in a subsequent commit: --- FAIL: TestAccComputeHttpHealthCheck_update (5.58s) testing.go:131: Step 1 error: Error applying: 1 error(s) occurred: * 1 error(s) occurred: * 1 error(s) occurred: * Error patching HttpHealthCheck: googleapi: Error 400: Invalid value for field 'resource.port': '0'. Must be greater than or equal to 1 More details: Reason: invalid, Message: Invalid value for field 'resource.port': '0'. Must be greater than or equal to 1 Reason: invalid, Message: Invalid value for field 'resource.checkIntervalSec': '0'. Must be greater than or equal to 1 Reason: invalid, Message: Invalid value for field 'resource.timeoutSec': '0'. Must be greater than or equal to 1 --- ...resource_compute_http_health_check_test.go | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/builtin/providers/google/resource_compute_http_health_check_test.go b/builtin/providers/google/resource_compute_http_health_check_test.go index ac98540dda..bc987af19b 100644 --- a/builtin/providers/google/resource_compute_http_health_check_test.go +++ b/builtin/providers/google/resource_compute_http_health_check_test.go @@ -25,6 +25,32 @@ func TestAccComputeHttpHealthCheck_basic(t *testing.T) { }) } +func TestAccComputeHttpHealthCheck_update(t *testing.T) { + var healthCheck compute.HttpHealthCheck + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeHttpHealthCheckDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccComputeHttpHealthCheck_update1, + Check: resource.ComposeTestCheckFunc( + testAccCheckComputeHttpHealthCheckExists( + "google_compute_http_health_check.foobar", &healthCheck), + ), + }, + resource.TestStep{ + Config: testAccComputeHttpHealthCheck_update2, + Check: resource.ComposeTestCheckFunc( + testAccCheckComputeHttpHealthCheckExists( + "google_compute_http_health_check.foobar", &healthCheck), + ), + }, + }, + }) +} + func testAccCheckComputeHttpHealthCheckDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) @@ -83,3 +109,22 @@ resource "google_compute_http_health_check" "foobar" { unhealthy_threshold = 3 } ` + +const testAccComputeHttpHealthCheck_update1 = ` +resource "google_compute_http_health_check" "foobar" { + name = "terraform-test" + description = "Resource created for Terraform acceptance testing" + request_path = "/not_default" +} +` + +/* Change description, restore request_path to default, and change +* thresholds from defaults */ +const testAccComputeHttpHealthCheck_update2 = ` +resource "google_compute_http_health_check" "foobar" { + name = "terraform-test" + description = "Resource updated for Terraform acceptance testing" + healthy_threshold = 10 + unhealthy_threshold = 10 +} +`