Skip to content

Commit

Permalink
Making the location dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Aug 20, 2017
1 parent d79ad8f commit 59f3d67
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 99 deletions.
6 changes: 3 additions & 3 deletions azurerm/import_arm_postgresql_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestAccAzureRMPostgreSQLConfiguration_importBackslashQuote(t *testing.T) {
resourceName := "azurerm_postgresql_configuration.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLConfiguration_backslashQuote(ri)
config := testAccAzureRMPostgreSQLConfiguration_backslashQuote(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -34,7 +34,7 @@ func TestAccAzureRMPostgreSQLConfiguration_importClientMinMessages(t *testing.T)
resourceName := "azurerm_postgresql_configuration.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLConfiguration_clientMinMessages(ri)
config := testAccAzureRMPostgreSQLConfiguration_clientMinMessages(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -57,7 +57,7 @@ func TestAccAzureRMPostgreSQLConfiguration_importDeadlockTimeout(t *testing.T) {
resourceName := "azurerm_postgresql_configuration.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLConfiguration_deadlockTimeout(ri)
config := testAccAzureRMPostgreSQLConfiguration_deadlockTimeout(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
2 changes: 1 addition & 1 deletion azurerm/import_arm_postgresql_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestAccAzureRMPostgreSQLDatabase_importBasic(t *testing.T) {
resourceName := "azurerm_postgresql_database.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLDatabase_basic(ri)
config := testAccAzureRMPostgreSQLDatabase_basic(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
2 changes: 1 addition & 1 deletion azurerm/import_arm_postgresql_firewall_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestAccAzureRMPostgreSQLFirewallRule_importBasic(t *testing.T) {
resourceName := "azurerm_postgresql_firewall_rule.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLFirewallRule_basic(ri)
config := testAccAzureRMPostgreSQLFirewallRule_basic(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
4 changes: 2 additions & 2 deletions azurerm/import_arm_postgresql_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestAccAzureRMPostgreSQLServer_importBasicNinePointFive(t *testing.T) {
resourceName := "azurerm_postgresql_server.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLServer_basicNinePointFive(ri)
config := testAccAzureRMPostgreSQLServer_basicNinePointFive(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -37,7 +37,7 @@ func TestAccAzureRMPostgreSQLServer_importBasicNinePointSix(t *testing.T) {
resourceName := "azurerm_postgresql_server.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLServer_basicNinePointSix(ri)
config := testAccAzureRMPostgreSQLServer_basicNinePointSix(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
56 changes: 30 additions & 26 deletions azurerm/resource_arm_postgresql_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (

func TestAccAzureRMPostgreSQLConfiguration_backslashQuote(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLConfiguration_backslashQuote(ri)
serverOnlyConfig := testAccAzureRMPostgreSQLConfiguration_empty(ri)
location := testLocation()
config := testAccAzureRMPostgreSQLConfiguration_backslashQuote(ri, location)
serverOnlyConfig := testAccAzureRMPostgreSQLConfiguration_empty(ri, location)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -39,8 +40,9 @@ func TestAccAzureRMPostgreSQLConfiguration_backslashQuote(t *testing.T) {

func TestAccAzureRMPostgreSQLConfiguration_clientMinMessages(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLConfiguration_clientMinMessages(ri)
serverOnlyConfig := testAccAzureRMPostgreSQLConfiguration_empty(ri)
location := testLocation()
config := testAccAzureRMPostgreSQLConfiguration_clientMinMessages(ri, location)
serverOnlyConfig := testAccAzureRMPostgreSQLConfiguration_empty(ri, location)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -66,8 +68,9 @@ func TestAccAzureRMPostgreSQLConfiguration_clientMinMessages(t *testing.T) {

func TestAccAzureRMPostgreSQLConfiguration_deadlockTimeout(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLConfiguration_deadlockTimeout(ri)
serverOnlyConfig := testAccAzureRMPostgreSQLConfiguration_empty(ri)
location := testLocation()
config := testAccAzureRMPostgreSQLConfiguration_deadlockTimeout(ri, location)
serverOnlyConfig := testAccAzureRMPostgreSQLConfiguration_empty(ri, location)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -179,20 +182,20 @@ func testCheckAzureRMPostgreSQLConfigurationDestroy(s *terraform.State) error {
return nil
}

func testAccAzureRMPostgreSQLConfiguration_backslashQuote(rInt int) string {
return testAccAzureRMPostgreSQLConfiguration_template(rInt, "backslash_quote", "on")
func testAccAzureRMPostgreSQLConfiguration_backslashQuote(rInt int, location string) string {
return testAccAzureRMPostgreSQLConfiguration_template(rInt, location, "backslash_quote", "on")
}

func testAccAzureRMPostgreSQLConfiguration_clientMinMessages(rInt int) string {
return testAccAzureRMPostgreSQLConfiguration_template(rInt, "client_min_messages", "DEBUG5")
func testAccAzureRMPostgreSQLConfiguration_clientMinMessages(rInt int, location string) string {
return testAccAzureRMPostgreSQLConfiguration_template(rInt, location, "client_min_messages", "DEBUG5")
}

func testAccAzureRMPostgreSQLConfiguration_deadlockTimeout(rInt int) string {
return testAccAzureRMPostgreSQLConfiguration_template(rInt, "deadlock_timeout", "5000")
func testAccAzureRMPostgreSQLConfiguration_deadlockTimeout(rInt int, location string) string {
return testAccAzureRMPostgreSQLConfiguration_template(rInt, location, "deadlock_timeout", "5000")
}

func testAccAzureRMPostgreSQLConfiguration_template(rInt int, name string, value string) string {
server := testAccAzureRMPostgreSQLConfiguration_empty(rInt)
func testAccAzureRMPostgreSQLConfiguration_template(rInt int, location string, name string, value string) string {
server := testAccAzureRMPostgreSQLConfiguration_empty(rInt, location)
config := fmt.Sprintf(`
resource "azurerm_postgresql_configuration" "test" {
name = "%s"
Expand All @@ -204,28 +207,29 @@ resource "azurerm_postgresql_configuration" "test" {
return server + config
}

func testAccAzureRMPostgreSQLConfiguration_empty(rInt int) string {
func testAccAzureRMPostgreSQLConfiguration_empty(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_postgresql_server" "test" {
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
name = "PGSQLB50"
name = "PGSQLB50"
capacity = 50
tier = "Basic"
tier = "Basic"
}
administrator_login = "acctestun"
administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
version = "9.6"
storage_mb = 51200
ssl_enforcement = "Enabled"
version = "9.6"
storage_mb = 51200
ssl_enforcement = "Enabled"
}
`, rInt, rInt)
`, rInt, location, rInt)
}
27 changes: 14 additions & 13 deletions azurerm/resource_arm_postgresql_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestAccAzureRMPostgreSQLDatabase_basic(t *testing.T) {
resourceName := "azurerm_postgresql_database.test"
ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLDatabase_basic(ri)
config := testAccAzureRMPostgreSQLDatabase_basic(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -88,28 +88,29 @@ func testCheckAzureRMPostgreSQLDatabaseDestroy(s *terraform.State) error {
return nil
}

func testAccAzureRMPostgreSQLDatabase_basic(rInt int) string {
func testAccAzureRMPostgreSQLDatabase_basic(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_postgresql_server" "test" {
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
name = "PGSQLB50"
name = "PGSQLB50"
capacity = 50
tier = "Basic"
tier = "Basic"
}
administrator_login = "acctestun"
administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
version = "9.6"
storage_mb = 51200
ssl_enforcement = "Enabled"
version = "9.6"
storage_mb = 51200
ssl_enforcement = "Enabled"
}
resource "azurerm_postgresql_database" "test" {
Expand All @@ -119,5 +120,5 @@ resource "azurerm_postgresql_database" "test" {
charset = "UTF8"
collation = "English_United States.1252"
}
`, rInt, rInt, rInt)
`, rInt, location, rInt, rInt)
}
26 changes: 13 additions & 13 deletions azurerm/resource_arm_postgresql_firewall_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestAccAzureRMPostgreSQLFirewallRule_basic(t *testing.T) {
resourceName := "azurerm_postgresql_firewall_rule.test"
ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLFirewallRule_basic(ri)
config := testAccAzureRMPostgreSQLFirewallRule_basic(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -88,29 +88,29 @@ func testCheckAzureRMPostgreSQLFirewallRuleDestroy(s *terraform.State) error {
return nil
}

func testAccAzureRMPostgreSQLFirewallRule_basic(rInt int) string {
func testAccAzureRMPostgreSQLFirewallRule_basic(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_postgresql_server" "test" {
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
name = "PGSQLB50"
name = "PGSQLB50"
capacity = 50
tier = "Basic"
tier = "Basic"
}
administrator_login = "acctestun"
administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
version = "9.6"
storage_mb = 51200
ssl_enforcement = "Enabled"
version = "9.6"
storage_mb = 51200
ssl_enforcement = "Enabled"
}
resource "azurerm_postgresql_firewall_rule" "test" {
Expand All @@ -120,5 +120,5 @@ resource "azurerm_postgresql_firewall_rule" "test" {
start_ip_address = "0.0.0.0"
end_ip_address = "255.255.255.255"
}
`, rInt, rInt, rInt)
`, rInt, location, rInt, rInt)
}
Loading

0 comments on commit 59f3d67

Please sign in to comment.