Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbai committed Nov 7, 2024
1 parent 2d2ae10 commit 44780ff
Showing 1 changed file with 68 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,37 @@ import (

type DataProtectionBackupPolicyPostgreSQLResource struct{}

func TestAccDataProtectionBackupPolicyPostgreSQL_basicDeprecatedInV5(t *testing.T) {
if features.FivePointOhBeta() {
t.Skip("this test requires 4.0 mode")
}
data := acceptance.BuildTestData(t, "azurerm_data_protection_backup_policy_postgresql", "test")
r := DataProtectionBackupPolicyPostgreSQLResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicDeprecatedInV5(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(
"default_retention_duration",
"default_retention_rule.#",
"default_retention_rule.0.%",
"default_retention_rule.0.life_cycle.#",
"default_retention_rule.0.life_cycle.0.%",
"default_retention_rule.0.life_cycle.0.data_store_type",
"default_retention_rule.0.life_cycle.0.duration",
),
})
}

func TestAccDataProtectionBackupPolicyPostgreSQL_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_data_protection_backup_policy_postgresql", "test")
r := DataProtectionBackupPolicyPostgreSQLResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
if !features.FivePointOhBeta() {
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(
"default_retention_duration",
"default_retention_rule.#",
"default_retention_rule.0.%",
"default_retention_rule.0.life_cycle.#",
"default_retention_rule.0.life_cycle.0.%",
"default_retention_rule.0.life_cycle.0.data_store_type",
"default_retention_rule.0.life_cycle.0.duration",
),
},
data.ImportStep(),
})
}

func TestAccDataProtectionBackupPolicyPostgreSQL_requiresImportDeprecatedInV5(t *testing.T) {
if features.FivePointOhBeta() {
t.Skip("this test requires 4.0 mode")
})
return
}
data := acceptance.BuildTestData(t, "azurerm_data_protection_backup_policy_postgresql", "test")
r := DataProtectionBackupPolicyPostgreSQLResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicDeprecatedInV5(data),
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.RequiresImportErrorStep(r.requiresImportDeprecatedInV5),
data.ImportStep(),
})
}

Expand All @@ -90,49 +68,44 @@ func TestAccDataProtectionBackupPolicyPostgreSQL_requiresImport(t *testing.T) {
})
}

func TestAccDataProtectionBackupPolicyPostgreSQL_completeDeprecatedInV5(t *testing.T) {
if features.FivePointOhBeta() {
t.Skip("this test requires 4.0 mode")
}
data := acceptance.BuildTestData(t, "azurerm_data_protection_backup_policy_postgresql", "test")
r := DataProtectionBackupPolicyPostgreSQLResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.completeDeprecatedInV5(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(
"default_retention_duration",
"default_retention_rule.#",
"default_retention_rule.0.%",
"default_retention_rule.0.life_cycle.#",
"default_retention_rule.0.life_cycle.0.%",
"default_retention_rule.0.life_cycle.0.data_store_type",
"default_retention_rule.0.life_cycle.0.duration",
"retention_rule.0.duration",
"retention_rule.0.life_cycle.#",
"retention_rule.0.life_cycle.0.%",
"retention_rule.0.life_cycle.0.data_store_type",
"retention_rule.0.life_cycle.0.duration",
"retention_rule.1.duration",
"retention_rule.1.life_cycle.#",
"retention_rule.1.life_cycle.0.%",
"retention_rule.1.life_cycle.0.data_store_type",
"retention_rule.1.life_cycle.0.duration",
"retention_rule.2.duration",
"retention_rule.2.life_cycle.#",
"retention_rule.2.life_cycle.0.%",
"retention_rule.2.life_cycle.0.data_store_type",
"retention_rule.2.life_cycle.0.duration",
),
})
}

func TestAccDataProtectionBackupPolicyPostgreSQL_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_data_protection_backup_policy_postgresql", "test")
r := DataProtectionBackupPolicyPostgreSQLResource{}
if !features.FivePointOhBeta() {
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(
"default_retention_duration",
"default_retention_rule.#",
"default_retention_rule.0.%",
"default_retention_rule.0.life_cycle.#",
"default_retention_rule.0.life_cycle.0.%",
"default_retention_rule.0.life_cycle.0.data_store_type",
"default_retention_rule.0.life_cycle.0.duration",
"retention_rule.0.duration",
"retention_rule.0.life_cycle.#",
"retention_rule.0.life_cycle.0.%",
"retention_rule.0.life_cycle.0.data_store_type",
"retention_rule.0.life_cycle.0.duration",
"retention_rule.1.duration",
"retention_rule.1.life_cycle.#",
"retention_rule.1.life_cycle.0.%",
"retention_rule.1.life_cycle.0.data_store_type",
"retention_rule.1.life_cycle.0.duration",
"retention_rule.2.duration",
"retention_rule.2.life_cycle.#",
"retention_rule.2.life_cycle.0.%",
"retention_rule.2.life_cycle.0.data_store_type",
"retention_rule.2.life_cycle.0.duration",
),
})
return
}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data),
Expand Down Expand Up @@ -180,9 +153,10 @@ resource "azurerm_data_protection_backup_vault" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (r DataProtectionBackupPolicyPostgreSQLResource) basicDeprecatedInV5(data acceptance.TestData) string {
func (r DataProtectionBackupPolicyPostgreSQLResource) basic(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
if !features.FivePointOhBeta() {
return fmt.Sprintf(`
%s
resource "azurerm_data_protection_backup_policy_postgresql" "test" {
Expand All @@ -194,10 +168,7 @@ resource "azurerm_data_protection_backup_policy_postgresql" "test" {
default_retention_duration = "P4M"
}
`, template, data.RandomInteger)
}

func (r DataProtectionBackupPolicyPostgreSQLResource) basic(data acceptance.TestData) string {
template := r.template(data)
}
return fmt.Sprintf(`
%s
Expand All @@ -218,9 +189,10 @@ resource "azurerm_data_protection_backup_policy_postgresql" "test" {
`, template, data.RandomInteger)
}

func (r DataProtectionBackupPolicyPostgreSQLResource) requiresImportDeprecatedInV5(data acceptance.TestData) string {
config := r.basicDeprecatedInV5(data)
return fmt.Sprintf(`
func (r DataProtectionBackupPolicyPostgreSQLResource) requiresImport(data acceptance.TestData) string {
config := r.basic(data)
if !features.FivePointOhBeta() {
return fmt.Sprintf(`
%s
resource "azurerm_data_protection_backup_policy_postgresql" "import" {
Expand All @@ -232,10 +204,7 @@ resource "azurerm_data_protection_backup_policy_postgresql" "import" {
default_retention_duration = "P4M"
}
`, config)
}

func (r DataProtectionBackupPolicyPostgreSQLResource) requiresImport(data acceptance.TestData) string {
config := r.basic(data)
}
return fmt.Sprintf(`
%s
Expand All @@ -256,9 +225,10 @@ resource "azurerm_data_protection_backup_policy_postgresql" "import" {
`, config)
}

func (r DataProtectionBackupPolicyPostgreSQLResource) completeDeprecatedInV5(data acceptance.TestData) string {
func (r DataProtectionBackupPolicyPostgreSQLResource) complete(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
if !features.FivePointOhBeta() {
return fmt.Sprintf(`
%s
resource "azurerm_data_protection_backup_policy_postgresql" "test" {
Expand Down Expand Up @@ -302,10 +272,7 @@ resource "azurerm_data_protection_backup_policy_postgresql" "test" {
}
}
`, template, data.RandomInteger)
}

func (r DataProtectionBackupPolicyPostgreSQLResource) complete(data acceptance.TestData) string {
template := r.template(data)
}
return fmt.Sprintf(`
%s
Expand Down

0 comments on commit 44780ff

Please sign in to comment.