Make network name unique between each test run (#826)

* Make network name unique between each test run

* make fmt
This commit is contained in:
Vincent Roseberry 2017-12-06 12:36:00 -08:00 committed by GitHub
parent e8cd017aac
commit 9bebdd02f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -16,7 +17,7 @@ func TestAccDataSourceGoogleSubnetwork(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: TestAccDataSourceGoogleSubnetworkConfig, Config: testAccDataSourceGoogleSubnetwork(),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccDataSourceGoogleSubnetworkCheck("data.google_compute_subnetwork.my_subnetwork", "google_compute_subnetwork.foobar"), testAccDataSourceGoogleSubnetworkCheck("data.google_compute_subnetwork.my_subnetwork", "google_compute_subnetwork.foobar"),
), ),
@ -66,10 +67,11 @@ func testAccDataSourceGoogleSubnetworkCheck(data_source_name string, resource_na
} }
} }
var TestAccDataSourceGoogleSubnetworkConfig = ` func testAccDataSourceGoogleSubnetwork() string {
return fmt.Sprintf(`
resource "google_compute_network" "foobar" { resource "google_compute_network" "foobar" {
name = "network-test" name = "%s"
description = "my-description" description = "my-description"
} }
resource "google_compute_subnetwork" "foobar" { resource "google_compute_subnetwork" "foobar" {
@ -87,4 +89,5 @@ resource "google_compute_subnetwork" "foobar" {
data "google_compute_subnetwork" "my_subnetwork" { data "google_compute_subnetwork" "my_subnetwork" {
name = "${google_compute_subnetwork.foobar.name}" name = "${google_compute_subnetwork.foobar.name}"
} }
` `, acctest.RandomWithPrefix("network-test"))
}