Skip to content

Commit

Permalink
azurerm_storage_table_entities Data Source - Fix `items.x.propertie…
Browse files Browse the repository at this point in the history
…s` hold only one kv bug
  • Loading branch information
magodo committed Mar 12, 2024
1 parent ed0f26c commit affe4ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ func flattenEntityWithMetadata(entity map[string]interface{}) TableEntitiyDataSo

result := TableEntitiyDataSourceModel{}

properties := map[string]interface{}{}
for k, v := range entity {
properties := map[string]interface{}{}
if k == "PartitionKey" {
result.PartitionKey = v.(string)
continue
Expand Down Expand Up @@ -200,7 +200,6 @@ func flattenEntityWithMetadata(entity map[string]interface{}) TableEntitiyDataSo
}

properties[k+"@odata.type"] = dtype
result.Properties = properties
} else {
// special handling for property types that do not require the annotation to be present
// https://docs.microsoft.com/en-us/rest/api/storageservices/payload-format-for-table-service-operations#property-types-in-a-json-feed
Expand All @@ -223,9 +222,9 @@ func flattenEntityWithMetadata(entity map[string]interface{}) TableEntitiyDataSo
default:
log.Printf("[WARN] key %q with unexpected type %T", k, c)
}
result.Properties = properties
}
}
result.Properties = properties

return result
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestAccDataSourceStorageTableEntities_basic(t *testing.T) {
Config: StorageTableEntitiesDataSource{}.basicWithDataSource(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("items.#").HasValue("2"),
check.That(data.ResourceName).Key("items.0.properties.%").HasValue("2"),
),
},
})
Expand Down Expand Up @@ -74,7 +75,8 @@ resource "azurerm_storage_table_entity" "test" {
row_key = "testrow"
entity = {
testkey = "testval"
testkey1 = "testval11"
testkey2 = "testval12"
}
}
Expand All @@ -86,7 +88,8 @@ resource "azurerm_storage_table_entity" "test2" {
row_key = "testrow2"
entity = {
testkey = "testval2"
testkey1 = "testval21"
testkey2 = "testval22"
}
}
Expand All @@ -98,7 +101,8 @@ resource "azurerm_storage_table_entity" "testselector" {
row_key = "testrow"
entity = {
testkey = "testval"
testkey1 = "testval31"
testkey2 = "testval32"
testselector = "testselectorval"
}
}
Expand Down

0 comments on commit affe4ca

Please sign in to comment.