provider/google: Fix collisions in SQL instance acctests

This commit is contained in:
Paul Hinze 2016-01-04 18:04:55 -06:00
parent adf4280aff
commit 4c6c5f5798
1 changed files with 22 additions and 14 deletions

View File

@ -20,6 +20,7 @@ import (
func TestAccGoogleSqlDatabaseInstance_basic(t *testing.T) {
var instance sqladmin.DatabaseInstance
databaseID := genRandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -27,7 +28,8 @@ func TestAccGoogleSqlDatabaseInstance_basic(t *testing.T) {
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testGoogleSqlDatabaseInstance_basic,
Config: fmt.Sprintf(
testGoogleSqlDatabaseInstance_basic, databaseID),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleSqlDatabaseInstanceExists(
"google_sql_database_instance.instance", &instance),
@ -41,6 +43,7 @@ func TestAccGoogleSqlDatabaseInstance_basic(t *testing.T) {
func TestAccGoogleSqlDatabaseInstance_settings_basic(t *testing.T) {
var instance sqladmin.DatabaseInstance
databaseID := genRandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -48,7 +51,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_basic(t *testing.T) {
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testGoogleSqlDatabaseInstance_settings,
Config: fmt.Sprintf(
testGoogleSqlDatabaseInstance_settings, databaseID),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleSqlDatabaseInstanceExists(
"google_sql_database_instance.instance", &instance),
@ -62,6 +66,7 @@ func TestAccGoogleSqlDatabaseInstance_settings_basic(t *testing.T) {
func TestAccGoogleSqlDatabaseInstance_settings_upgrade(t *testing.T) {
var instance sqladmin.DatabaseInstance
databaseID := genRandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -69,7 +74,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_upgrade(t *testing.T) {
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testGoogleSqlDatabaseInstance_basic,
Config: fmt.Sprintf(
testGoogleSqlDatabaseInstance_basic, databaseID),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleSqlDatabaseInstanceExists(
"google_sql_database_instance.instance", &instance),
@ -78,7 +84,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_upgrade(t *testing.T) {
),
},
resource.TestStep{
Config: testGoogleSqlDatabaseInstance_settings,
Config: fmt.Sprintf(
testGoogleSqlDatabaseInstance_settings, databaseID),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleSqlDatabaseInstanceExists(
"google_sql_database_instance.instance", &instance),
@ -92,6 +99,7 @@ func TestAccGoogleSqlDatabaseInstance_settings_upgrade(t *testing.T) {
func TestAccGoogleSqlDatabaseInstance_settings_downgrade(t *testing.T) {
var instance sqladmin.DatabaseInstance
databaseID := genRandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -99,7 +107,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_downgrade(t *testing.T) {
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testGoogleSqlDatabaseInstance_settings,
Config: fmt.Sprintf(
testGoogleSqlDatabaseInstance_settings, databaseID),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleSqlDatabaseInstanceExists(
"google_sql_database_instance.instance", &instance),
@ -108,7 +117,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_downgrade(t *testing.T) {
),
},
resource.TestStep{
Config: testGoogleSqlDatabaseInstance_basic,
Config: fmt.Sprintf(
testGoogleSqlDatabaseInstance_basic, databaseID),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleSqlDatabaseInstanceExists(
"google_sql_database_instance.instance", &instance),
@ -319,9 +329,7 @@ func testAccGoogleSqlDatabaseInstanceDestroy(s *terraform.State) error {
return nil
}
var databaseId = genRandInt()
var testGoogleSqlDatabaseInstance_basic = fmt.Sprintf(`
var testGoogleSqlDatabaseInstance_basic = `
resource "google_sql_database_instance" "instance" {
name = "tf-lw-%d"
region = "us-central"
@ -330,9 +338,9 @@ resource "google_sql_database_instance" "instance" {
crash_safe_replication = false
}
}
`, databaseId)
`
var testGoogleSqlDatabaseInstance_settings = fmt.Sprintf(`
var testGoogleSqlDatabaseInstance_settings = `
resource "google_sql_database_instance" "instance" {
name = "tf-lw-%d"
region = "us-central"
@ -361,11 +369,11 @@ resource "google_sql_database_instance" "instance" {
activation_policy = "ON_DEMAND"
}
}
`, databaseId)
`
// Note - this test is not feasible to run unless we generate
// backups first.
var testGoogleSqlDatabaseInstance_replica = fmt.Sprintf(`
var testGoogleSqlDatabaseInstance_replica = `
resource "google_sql_database_instance" "instance_master" {
name = "tf-lw-%d"
database_version = "MYSQL_5_6"
@ -406,4 +414,4 @@ resource "google_sql_database_instance" "instance" {
verify_server_certificate = false
}
}
`, genRandInt(), genRandInt())
`