Skip to content

Commit

Permalink
deprecate 0.11 syntax in tests (datasources) (#2593)
Browse files Browse the repository at this point in the history
  • Loading branch information
megan07 authored and rileykarson committed Nov 11, 2019
1 parent ec70d41 commit 5d1b341
Show file tree
Hide file tree
Showing 32 changed files with 275 additions and 259 deletions.
33 changes: 18 additions & 15 deletions third_party/terraform/tests/data_source_container_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,29 @@ func TestDataSourceGoogleContainerRegistryImage(t *testing.T) {

const testAccCheckGoogleContainerRegistryImage_basic = `
data "google_container_registry_image" "test" {
project = "foo"
region = "bar"
name = "baz"
project = "foo"
region = "bar"
name = "baz"
}
data "google_container_registry_image" "test2" {
project = "foo"
region = "bar"
name = "baz"
tag = "qux"
project = "foo"
region = "bar"
name = "baz"
tag = "qux"
}
data "google_container_registry_image" "test3" {
project = "foo"
region = "bar"
name = "baz"
digest = "1234"
project = "foo"
region = "bar"
name = "baz"
digest = "1234"
}
data "google_container_registry_image" "testScoped" {
project = "example.com:foo"
region = "bar"
name = "baz"
tag = "qux"
project = "example.com:foo"
region = "bar"
name = "baz"
tag = "qux"
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,23 @@ func testAccCheckGoogleBillingAccount_byName(name string) string {
return fmt.Sprintf(`
data "google_billing_account" "acct" {
billing_account = "%s"
}`, name)
}
`, name)
}

func testAccCheckGoogleBillingAccount_byNameClosed(name string) string {
return fmt.Sprintf(`
data "google_billing_account" "acct" {
billing_account = "%s"
open = false
}`, name)
open = false
}
`, name)
}

func testAccCheckGoogleBillingAccount_byDisplayName(name string) string {
return fmt.Sprintf(`
data "google_billing_account" "acct" {
display_name = "%s"
}`, name)
}
`, name)
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ resource "google_storage_bucket" "bucket" {
resource "google_storage_bucket_object" "archive" {
name = "index.zip"
bucket = "${google_storage_bucket.bucket.name}"
bucket = google_storage_bucket.bucket.name
source = "%s"
}
Expand All @@ -52,15 +52,15 @@ resource "google_cloudfunctions_function" "function_http" {
runtime = "nodejs8"
description = "test function"
available_memory_mb = 128
source_archive_bucket = "${google_storage_bucket.bucket.name}"
source_archive_object = "${google_storage_bucket_object.archive.name}"
source_archive_bucket = google_storage_bucket.bucket.name
source_archive_object = google_storage_bucket_object.archive.name
trigger_http = true
timeout = 61
entry_point = "helloGET"
}
data "google_cloudfunctions_function" "function_http" {
name = "${google_cloudfunctions_function.function_http.name}"
name = google_cloudfunctions_function.function_http.name
}
`, bucketName, zipFilePath, functionName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ func testAccCheckDataSourceComputeAddressDestroy(resource_name string) resource.
func testAccDataSourceComputeAddressConfig(rsName, dsName string) string {
return fmt.Sprintf(`
resource "google_compute_address" "%s" {
name = "address-test"
name = "address-test"
}
data "google_compute_address" "%s" {
name = "${google_compute_address.%s.name}"
name = google_compute_address.%s.name
}
`, rsName, dsName, rsName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func testAccDataSourceComputeBackendService_basic(serviceName, checkName string)
resource "google_compute_backend_service" "foobar" {
name = "%s"
description = "foobar backend service"
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
health_checks = [google_compute_http_health_check.zero.self_link]
}
resource "google_compute_http_health_check" "zero" {
Expand All @@ -43,7 +43,7 @@ resource "google_compute_http_health_check" "zero" {
}
data "google_compute_backend_service" "baz" {
name = "${google_compute_backend_service.foobar.name}"
name = google_compute_backend_service.foobar.name
}
`, serviceName, checkName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,22 @@ func testAccDataSourceGoogleForwardingRuleCheck(data_source_name string, resourc

func testAccDataSourceGoogleForwardingRuleConfig(poolName, ruleName string) string {
return fmt.Sprintf(`
resource "google_compute_target_pool" "foobar-tp" {
description = "Resource created for Terraform acceptance testing"
instances = ["us-central1-a/foo", "us-central1-b/bar"]
name = "%s"
}
resource "google_compute_forwarding_rule" "foobar-fr" {
description = "Resource created for Terraform acceptance testing"
ip_protocol = "UDP"
name = "%s"
port_range = "80-81"
target = "${google_compute_target_pool.foobar-tp.self_link}"
}
data "google_compute_forwarding_rule" "my_forwarding_rule" {
name = "${google_compute_forwarding_rule.foobar-fr.name}"
}
resource "google_compute_target_pool" "foobar-tp" {
description = "Resource created for Terraform acceptance testing"
instances = ["us-central1-a/foo", "us-central1-b/bar"]
name = "%s"
}
resource "google_compute_forwarding_rule" "foobar-fr" {
description = "Resource created for Terraform acceptance testing"
ip_protocol = "UDP"
name = "%s"
port_range = "80-81"
target = google_compute_target_pool.foobar-tp.self_link
}
data "google_compute_forwarding_rule" "my_forwarding_rule" {
name = google_compute_forwarding_rule.foobar-fr.name
}
`, poolName, ruleName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ func testAccDataSourceComputeGlobalAddressCheck(data_source_name string, resourc
func testAccDataSourceComputeGlobalAddressConfig(rsName, dsName string) string {
return fmt.Sprintf(`
resource "google_compute_global_address" "%s" {
name = "address-test"
name = "address-test"
}
data "google_compute_global_address" "%s" {
name = "${google_compute_global_address.%s.name}"
name = google_compute_global_address.%s.name
}
`, rsName, dsName, rsName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,22 @@ func testAccDataSourceCustomImageConfig(family, name string) string {
resource "google_compute_image" "image" {
family = "%s"
name = "%s"
source_disk = "${google_compute_disk.disk.self_link}"
source_disk = google_compute_disk.disk.self_link
}
resource "google_compute_disk" "disk" {
name = "%s-disk"
zone = "us-central1-b"
}
data "google_compute_image" "from_name" {
project = "${google_compute_image.image.project}"
name = "${google_compute_image.image.name}"
project = google_compute_image.image.project
name = google_compute_image.image.name
}
data "google_compute_image" "from_family" {
project = "${google_compute_image.image.project}"
family = "${google_compute_image.image.family}"
project = google_compute_image.image.project
family = google_compute_image.image.family
}
`, family, name, name)
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ resource "google_compute_instance" "test" {

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
image = data.google_compute_image.my_image.self_link
}
}

Expand All @@ -227,16 +227,16 @@ resource "google_compute_instance" "test" {

resource "google_compute_instance_group" "test" {
name = "tf-test-%s"
zone = "${google_compute_instance.test.zone}"
zone = google_compute_instance.test.zone

instances = [
"${google_compute_instance.test.self_link}",
google_compute_instance.test.self_link,
]
}

data "google_compute_instance_group" "test" {
name = "${google_compute_instance_group.test.name}"
zone = "${google_compute_instance_group.test.zone}"
name = google_compute_instance_group.test.name
zone = google_compute_instance_group.test.zone
}
`, acctest.RandString(10), acctest.RandString(10))
}
Expand All @@ -255,7 +255,7 @@ resource "google_compute_instance" "test" {

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
image = data.google_compute_image.my_image.self_link
}
}

Expand All @@ -270,7 +270,7 @@ resource "google_compute_instance" "test" {

resource "google_compute_instance_group" "test" {
name = "tf-test-%s"
zone = "${google_compute_instance.test.zone}"
zone = google_compute_instance.test.zone

named_port {
name = "http"
Expand All @@ -283,13 +283,13 @@ resource "google_compute_instance_group" "test" {
}

instances = [
"${google_compute_instance.test.self_link}",
google_compute_instance.test.self_link,
]
}

data "google_compute_instance_group" "test" {
name = "${google_compute_instance_group.test.name}"
zone = "${google_compute_instance_group.test.zone}"
name = google_compute_instance_group.test.name
zone = google_compute_instance_group.test.zone
}
`, acctest.RandString(10), acctest.RandString(10))
}
Expand All @@ -302,13 +302,13 @@ data "google_compute_image" "my_image" {
}

resource "google_compute_instance_template" "igm-basic" {
name = "%s"
name = "%s"
machine_type = "n1-standard-1"

disk {
source_image = "${data.google_compute_image.my_image.self_link}"
auto_delete = true
boot = true
source_image = data.google_compute_image.my_image.self_link
auto_delete = true
boot = true
}

network_interface {
Expand All @@ -317,24 +317,24 @@ resource "google_compute_instance_template" "igm-basic" {
}

resource "google_compute_instance_group_manager" "igm" {
name = "%s"
name = "%s"
<% if version.nil? || version == 'ga' -%>
instance_template = "${google_compute_instance_template.igm-basic.self_link}"
instance_template = google_compute_instance_template.igm-basic.self_link
<% else -%>
version {
instance_template = "${google_compute_instance_template.igm-basic.self_link}"
name = "primary"
instance_template = google_compute_instance_template.igm-basic.self_link
name = "primary"
}
<% end -%>
base_instance_name = "igm"
zone = "us-central1-a"
target_size = 10
zone = "us-central1-a"
target_size = 10

wait_for_instances = true
}

data "google_compute_instance_group" "test" {
self_link = "${google_compute_instance_group_manager.igm.instance_group}"
self_link = google_compute_instance_group_manager.igm.instance_group
}
`, acctest.RandomWithPrefix("test-igm"), acctest.RandomWithPrefix("test-igm"))
}
Loading

0 comments on commit 5d1b341

Please sign in to comment.