Skip to content

Commit

Permalink
azurerm_storage_account - Mark shared_properties.smb as O+C (#21226)
Browse files Browse the repository at this point in the history
* `azurerm_storage_account` - Mark `shared_properties.smb` as O+C

* Codify comment: https://github.com/hashicorp/terraform-provider-azurerm/pull/21226\#discussion_r1154300617

* revert the code change & update the test
  • Loading branch information
magodo authored Dec 13, 2023
1 parent 008bb9c commit 89b9d18
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/services/storage/storage_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3641,6 +3641,7 @@ func flattenedSharePropertiesSMB(input *storage.SmbSetting) []interface{} {
if input == nil {
return []interface{}{}
}

versions := []interface{}{}
if input.Versions != nil {
versions = utils.FlattenStringSliceWithDelimiter(input.Versions, ";")
Expand Down
60 changes: 56 additions & 4 deletions internal/services/storage/storage_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1496,13 +1496,13 @@ func TestAccStorageAccount_isSftpEnabled(t *testing.T) {
})
}

func TestAccStorageAccount_emptyShareProperties(t *testing.T) {
func TestAccStorageAccount_minimalShareProperties(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.emptyShareProperties(data),
Config: r.minimalShareProperties(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand All @@ -1511,6 +1511,21 @@ func TestAccStorageAccount_emptyShareProperties(t *testing.T) {
})
}

func TestAccStorageAccount_minimalSharePropertiesPremiumFileStorage(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.minimalSharePropertiesPremiumFileStorage(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("share_properties.0.smb"),
})
}

func (r StorageAccountResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := commonids.ParseStorageAccountID(state.ID)
if err != nil {
Expand Down Expand Up @@ -4329,7 +4344,7 @@ resource "azurerm_storage_account" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomString, scope)
}

func (r StorageAccountResource) emptyShareProperties(data acceptance.TestData) string {
func (r StorageAccountResource) minimalShareProperties(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand All @@ -4349,7 +4364,44 @@ resource "azurerm_storage_account" "test" {
account_replication_type = "LRS"
account_kind = "StorageV2"
share_properties {}
share_properties {
retention_policy {
days = 5
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r StorageAccountResource) minimalSharePropertiesPremiumFileStorage(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-storage-%[1]d"
location = "%[2]s"
}
resource "azurerm_storage_account" "test" {
name = "unlikely23exst2acct%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Premium"
account_replication_type = "LRS"
account_kind = "FileStorage"
share_properties {
retention_policy {
days = 5
}
}
lifecycle {
ignore_changes = [share_properties.0.smb]
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}
Expand Down

0 comments on commit 89b9d18

Please sign in to comment.