mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-14 09:34:03 -06:00
provider/google: Some more collision avoidance test tweaks
This commit is contained in:
parent
65fb52a38e
commit
c4aff4a585
@ -4,12 +4,14 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
"google.golang.org/api/compute/v1"
|
||||
)
|
||||
|
||||
func TestAccComputeDisk_basic(t *testing.T) {
|
||||
diskName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
|
||||
var disk compute.Disk
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
@ -18,7 +20,7 @@ func TestAccComputeDisk_basic(t *testing.T) {
|
||||
CheckDestroy: testAccCheckComputeDiskDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeDisk_basic,
|
||||
Config: testAccComputeDisk_basic(diskName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeDiskExists(
|
||||
"google_compute_disk.foobar", &disk),
|
||||
@ -75,11 +77,13 @@ func testAccCheckComputeDiskExists(n string, disk *compute.Disk) resource.TestCh
|
||||
}
|
||||
}
|
||||
|
||||
const testAccComputeDisk_basic = `
|
||||
func testAccComputeDisk_basic(diskName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_disk" "foobar" {
|
||||
name = "terraform-test"
|
||||
name = "%s"
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
size = 50
|
||||
type = "pd-ssd"
|
||||
zone = "us-central1-a"
|
||||
}`
|
||||
}`, diskName)
|
||||
}
|
||||
|
@ -4,11 +4,14 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccComputeForwardingRule_basic(t *testing.T) {
|
||||
poolName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
ruleName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
@ -16,7 +19,7 @@ func TestAccComputeForwardingRule_basic(t *testing.T) {
|
||||
CheckDestroy: testAccCheckComputeForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeForwardingRule_basic,
|
||||
Config: testAccComputeForwardingRule_basic(poolName, ruleName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeForwardingRuleExists(
|
||||
"google_compute_forwarding_rule.foobar"),
|
||||
@ -27,6 +30,9 @@ func TestAccComputeForwardingRule_basic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccComputeForwardingRule_ip(t *testing.T) {
|
||||
addrName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
poolName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
ruleName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
@ -34,7 +40,7 @@ func TestAccComputeForwardingRule_ip(t *testing.T) {
|
||||
CheckDestroy: testAccCheckComputeForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeForwardingRule_ip,
|
||||
Config: testAccComputeForwardingRule_ip(addrName, poolName, ruleName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeForwardingRuleExists(
|
||||
"google_compute_forwarding_rule.foobar"),
|
||||
@ -89,36 +95,40 @@ func testAccCheckComputeForwardingRuleExists(n string) resource.TestCheckFunc {
|
||||
}
|
||||
}
|
||||
|
||||
const testAccComputeForwardingRule_basic = `
|
||||
func testAccComputeForwardingRule_basic(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 = "terraform-test"
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
instances = ["us-central1-a/foo", "us-central1-b/bar"]
|
||||
name = "%s"
|
||||
}
|
||||
resource "google_compute_forwarding_rule" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_protocol = "UDP"
|
||||
name = "terraform-test"
|
||||
port_range = "80-81"
|
||||
target = "${google_compute_target_pool.foobar-tp.self_link}"
|
||||
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}"
|
||||
}
|
||||
`, poolName, ruleName)
|
||||
}
|
||||
`
|
||||
|
||||
const testAccComputeForwardingRule_ip = `
|
||||
func testAccComputeForwardingRule_ip(addrName, poolName, ruleName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_address" "foo" {
|
||||
name = "foo"
|
||||
name = "%s"
|
||||
}
|
||||
resource "google_compute_target_pool" "foobar-tp" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
instances = ["us-central1-a/foo", "us-central1-b/bar"]
|
||||
name = "terraform-test"
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
instances = ["us-central1-a/foo", "us-central1-b/bar"]
|
||||
name = "%s"
|
||||
}
|
||||
resource "google_compute_forwarding_rule" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_address = "${google_compute_address.foo.address}"
|
||||
ip_protocol = "TCP"
|
||||
name = "terraform-test"
|
||||
port_range = "80-81"
|
||||
target = "${google_compute_target_pool.foobar-tp.self_link}"
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_address = "${google_compute_address.foo.address}"
|
||||
ip_protocol = "TCP"
|
||||
name = "%s"
|
||||
port_range = "80-81"
|
||||
target = "${google_compute_target_pool.foobar-tp.self_link}"
|
||||
}
|
||||
`, addrName, poolName, ruleName)
|
||||
}
|
||||
`
|
||||
|
Loading…
Reference in New Issue
Block a user