From ac5a2e1e358644f8616c15d2fff245031e9fa20c Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Thu, 7 Nov 2019 10:25:33 -0800 Subject: [PATCH] Test updates to not depend on id format. Also test fixes (#2609) * Test updates to not depend on id format. Also test fixes * Typo * location -> region in node pool test --- .../tests/resource_compute_ssl_certificate_test.go | 6 ++++-- .../terraform/tests/resource_compute_ssl_policy_test.go | 2 +- .../tests/resource_compute_target_http_proxy_test.go | 5 +++-- .../tests/resource_compute_target_https_proxy_test.go | 5 +++-- .../terraform/tests/resource_compute_url_map_test.go | 5 +++-- .../tests/resource_container_node_pool_test.go.erb | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/third_party/terraform/tests/resource_compute_ssl_certificate_test.go b/third_party/terraform/tests/resource_compute_ssl_certificate_test.go index 20cde1201f0a..4970fef84f19 100644 --- a/third_party/terraform/tests/resource_compute_ssl_certificate_test.go +++ b/third_party/terraform/tests/resource_compute_ssl_certificate_test.go @@ -45,14 +45,16 @@ func testAccCheckComputeSslCertificateExists(n string) resource.TestCheckFunc { } config := testAccProvider.Meta().(*Config) + // We don't specify a name, but it is saved during create + name := rs.Primary.Attributes["name"] found, err := config.clientCompute.SslCertificates.Get( - config.Project, rs.Primary.ID).Do() + config.Project, name).Do() if err != nil { return err } - if found.Name != rs.Primary.ID { + if found.Name != name { return fmt.Errorf("Certificate not found") } diff --git a/third_party/terraform/tests/resource_compute_ssl_policy_test.go b/third_party/terraform/tests/resource_compute_ssl_policy_test.go index 401a293de672..b63b1e57fc70 100644 --- a/third_party/terraform/tests/resource_compute_ssl_policy_test.go +++ b/third_party/terraform/tests/resource_compute_ssl_policy_test.go @@ -177,7 +177,7 @@ func testAccCheckComputeSslPolicyExists(n string, sslPolicy *compute.SslPolicy) return fmt.Errorf("Error Reading SSL Policy %s: %s", name, err) } - if found.Name != rs.Primary.ID { + if found.Name != name { return fmt.Errorf("SSL Policy not found") } diff --git a/third_party/terraform/tests/resource_compute_target_http_proxy_test.go b/third_party/terraform/tests/resource_compute_target_http_proxy_test.go index 194b5c8f46c2..52c88de7c495 100644 --- a/third_party/terraform/tests/resource_compute_target_http_proxy_test.go +++ b/third_party/terraform/tests/resource_compute_target_http_proxy_test.go @@ -54,14 +54,15 @@ func testAccCheckComputeTargetHttpProxyExists(n string) resource.TestCheckFunc { } config := testAccProvider.Meta().(*Config) + name := rs.Attributes["name"] found, err := config.clientCompute.TargetHttpProxies.Get( - config.Project, rs.Primary.ID).Do() + config.Project, name).Do() if err != nil { return err } - if found.Name != rs.Primary.ID { + if found.Name != name { return fmt.Errorf("TargetHttpProxy not found") } diff --git a/third_party/terraform/tests/resource_compute_target_https_proxy_test.go b/third_party/terraform/tests/resource_compute_target_https_proxy_test.go index 4529b86b5295..250645783f93 100644 --- a/third_party/terraform/tests/resource_compute_target_https_proxy_test.go +++ b/third_party/terraform/tests/resource_compute_target_https_proxy_test.go @@ -61,14 +61,15 @@ func testAccCheckComputeTargetHttpsProxyExists(n string, proxy *compute.TargetHt } config := testAccProvider.Meta().(*Config) + name := rs.Primary.Attributes["name"] found, err := config.clientCompute.TargetHttpsProxies.Get( - config.Project, rs.Primary.ID).Do() + config.Project, name).Do() if err != nil { return err } - if found.Name != rs.Primary.ID { + if found.Name != name { return fmt.Errorf("TargetHttpsProxy not found") } diff --git a/third_party/terraform/tests/resource_compute_url_map_test.go b/third_party/terraform/tests/resource_compute_url_map_test.go index 9251aabdc0d2..82e5d8b087e3 100644 --- a/third_party/terraform/tests/resource_compute_url_map_test.go +++ b/third_party/terraform/tests/resource_compute_url_map_test.go @@ -107,14 +107,15 @@ func testAccCheckComputeUrlMapExists(n string) resource.TestCheckFunc { } config := testAccProvider.Meta().(*Config) + name := rs.Primary.Attributes["name"] found, err := config.clientCompute.UrlMaps.Get( - config.Project, rs.Primary.ID).Do() + config.Project, name).Do() if err != nil { return err } - if found.Name != rs.Primary.ID { + if found.Name != name { return fmt.Errorf("Url map not found") } return nil diff --git a/third_party/terraform/tests/resource_container_node_pool_test.go.erb b/third_party/terraform/tests/resource_container_node_pool_test.go.erb index b4b4ef9b2609..8a0e526d52bb 100644 --- a/third_party/terraform/tests/resource_container_node_pool_test.go.erb +++ b/third_party/terraform/tests/resource_container_node_pool_test.go.erb @@ -763,7 +763,7 @@ resource "google_compute_subnetwork" "container_subnetwork" { name = "${google_compute_network.container_network.name}" network = "${google_compute_network.container_network.name}" ip_cidr_range = "10.0.36.0/24" - location = "us-central1" + region = "us-central1" private_ip_google_access = true secondary_ip_range {