Skip to content

Commit

Permalink
fix GH 27751 (#27762)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbai authored Oct 29, 2024
1 parent 14f6b1b commit c2844c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ func resourceDataProtectionBackupVaultRead(d *pluginsdk.ResourceData, meta inter
}
crossRegionStoreEnabled := false
if featureSetting := model.Properties.FeatureSettings; featureSetting != nil {
if featureSetting := model.Properties.FeatureSettings; featureSetting != nil {
if pointer.From(featureSetting.CrossRegionRestoreSettings.State) == backupvaults.CrossRegionRestoreStateEnabled {
if crossRegionRestore := featureSetting.CrossRegionRestoreSettings; crossRegionRestore != nil {
if pointer.From(crossRegionRestore.State) == backupvaults.CrossRegionRestoreStateEnabled {
crossRegionStoreEnabled = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ func TestAccDataProtectionBackupVault_crossRegionRestore(t *testing.T) {
r := DataProtectionBackupVaultResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.crossRegionRestore(data),
Config: r.crossRegionRestore(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.crossRegionRestore(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -192,7 +199,7 @@ resource "azurerm_data_protection_backup_vault" "test" {
`, template, data.RandomInteger)
}

func (r DataProtectionBackupVaultResource) crossRegionRestore(data acceptance.TestData) string {
func (r DataProtectionBackupVaultResource) crossRegionRestore(data acceptance.TestData, enabled bool) string {
template := r.template(data)
return fmt.Sprintf(`
%s
Expand All @@ -203,9 +210,9 @@ resource "azurerm_data_protection_backup_vault" "test" {
location = azurerm_resource_group.test.location
datastore_type = "VaultStore"
redundancy = "GeoRedundant"
cross_region_restore_enabled = true
cross_region_restore_enabled = %t
}
`, template, data.RandomInteger)
`, template, data.RandomInteger, enabled)
}

func (r DataProtectionBackupVaultResource) requiresImport(data acceptance.TestData) string {
Expand Down

0 comments on commit c2844c0

Please sign in to comment.