Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql: fix replace acctests #27981

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -604,28 +604,6 @@ func TestAccPostgresqlFlexibleServer_publicNetworkAccessEnabled(t *testing.T) {
})
}

func TestAccPostgresqlFlexibleServer_recreateWithLowerStorageMb(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_postgresql_flexible_server", "test")
r := PostgresqlFlexibleServerResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.recreateWithLowerStorageMb(data, data.RandomInteger, "65536"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("administrator_password", "create_mode"),
{
Config: r.recreateWithLowerStorageMb(data, data.RandomInteger+1, "32768"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("administrator_password", "create_mode"),
})
}

func (PostgresqlFlexibleServerResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := servers.ParseFlexibleServerID(state.ID)
if err != nil {
Expand Down Expand Up @@ -1440,21 +1418,3 @@ resource "azurerm_postgresql_flexible_server" "test" {
}
`, r.template(data), data.RandomInteger, publicNetworkAccessEnabled)
}

func (r PostgresqlFlexibleServerResource) recreateWithLowerStorageMb(data acceptance.TestData, nameSuffix int, storageMb string) string {
return fmt.Sprintf(`
%s
resource "azurerm_postgresql_flexible_server" "test" {
name = "acctest-fs-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
storage_mb = %s
storage_tier = "P6"
version = "12"
sku_name = "GP_Standard_D2s_v3"
zone = "2"
}
`, r.template(data), nameSuffix, storageMb)
}
24 changes: 5 additions & 19 deletions internal/services/postgres/postgresql_server_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,6 @@ func TestAccPostgreSQLServer_updated(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_postgresql_server", "test")
r := PostgreSQLServerResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.gp(data, "9.6"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("administrator_login_password"),
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
Expand Down Expand Up @@ -207,13 +200,6 @@ func TestAccPostgreSQLServer_updateSKU(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_postgresql_server", "test")
r := PostgreSQLServerResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.sku(data, "10.0", "B_Gen5_2"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("administrator_login_password"),
{
Config: r.sku(data, "10.0", "GP_Gen5_2"),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -222,7 +208,7 @@ func TestAccPostgreSQLServer_updateSKU(t *testing.T) {
},
data.ImportStep("administrator_login_password"),
{
Config: r.sku(data, "10.0", "MO_Gen5_16"),
Config: r.sku(data, "10.0", "GP_Gen5_4"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -548,7 +534,7 @@ resource "azurerm_resource_group" "test" {
}

resource "azurerm_storage_account" "test" {
name = "acct%[1]d"
name = "accsa%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
Expand Down Expand Up @@ -627,10 +613,10 @@ resource "azurerm_postgresql_server" "test" {
storage_mb = 640000

backup_retention_days = 14
geo_redundant_backup_enabled = false
auto_grow_enabled = false
geo_redundant_backup_enabled = true
auto_grow_enabled = true

infrastructure_encryption_enabled = false
infrastructure_encryption_enabled = true
public_network_access_enabled = true
ssl_enforcement_enabled = false
ssl_minimal_tls_version_enforced = "TLSEnforcementDisabled"
Expand Down
Loading