helper/schema: fix failing tests

This commit is contained in:
Mitchell Hashimoto 2014-10-08 18:25:31 -07:00
parent 00bdef3093
commit 753f6c6f8e
2 changed files with 40 additions and 0 deletions

View File

@ -620,6 +620,9 @@ func (m schemaMap) diffString(
if o != nil && n == nil { if o != nil && n == nil {
removed = true removed = true
} }
if removed && schema.Computed {
return nil
}
diff.Attributes[k] = schema.finalizeDiff(&terraform.ResourceAttrDiff{ diff.Attributes[k] = schema.finalizeDiff(&terraform.ResourceAttrDiff{
Old: os, Old: os,

View File

@ -864,6 +864,43 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
{
Schema: map[string]*Schema{
"config_vars": &Schema{
Type: TypeMap,
},
},
State: &terraform.InstanceState{
Attributes: map[string]string{
"config_vars.foo": "bar",
},
},
Config: map[string]interface{}{
"config_vars": []interface{}{
map[string]interface{}{
"bar": "baz",
},
},
},
Diff: &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"config_vars.foo": &terraform.ResourceAttrDiff{
Old: "bar",
NewRemoved: true,
},
"config_vars.bar": &terraform.ResourceAttrDiff{
Old: "",
New: "baz",
},
},
},
Err: false,
},
{ {
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"config_vars": &Schema{ "config_vars": &Schema{