helper/schema: empty map values should show up in diff [GH-968]

This commit is contained in:
Mitchell Hashimoto 2015-02-17 15:22:45 -08:00
parent e9778c85a5
commit 5c06cc386a
2 changed files with 34 additions and 2 deletions

View File

@ -661,10 +661,10 @@ func (m schemaMap) diffMap(
// Now we compare, preferring values from the config map // Now we compare, preferring values from the config map
for k, v := range configMap { for k, v := range configMap {
old := stateMap[k] old, ok := stateMap[k]
delete(stateMap, k) delete(stateMap, k)
if old == v && !all { if old == v && ok && !all {
continue continue
} }

View File

@ -2063,6 +2063,38 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #52 - Map with empty value
{
Schema: map[string]*Schema{
"vars": &Schema{
Type: TypeMap,
},
},
State: nil,
Config: map[string]interface{}{
"vars": map[string]interface{}{
"foo": "",
},
},
Diff: &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"vars.#": &terraform.ResourceAttrDiff{
Old: "0",
New: "1",
},
"vars.foo": &terraform.ResourceAttrDiff{
Old: "",
New: "",
},
},
},
Err: false,
},
} }
for i, tc := range cases { for i, tc := range cases {