helper/schema: diff of zero value in state with lack of value should not

diff
This commit is contained in:
Mitchell Hashimoto 2015-02-17 11:10:45 -08:00
parent 1752c93e0c
commit b778a65a83
2 changed files with 26 additions and 0 deletions

View File

@ -810,6 +810,9 @@ func (m schemaMap) diffString(
originalN = n
n = schema.StateFunc(n)
}
if n == nil {
n = schema.Type.Zero()
}
if err := mapstructure.WeakDecode(o, &os); err != nil {
return fmt.Errorf("%s: %s", k, err)
}

View File

@ -1943,6 +1943,29 @@ func TestSchemaMap_Diff(t *testing.T) {
Diff: nil,
Err: false,
},
// #48
{
Schema: map[string]*Schema{
"port": &Schema{
Type: TypeBool,
Optional: true,
ForceNew: true,
},
},
State: &terraform.InstanceState{
Attributes: map[string]string{
"port": "false",
},
},
Config: map[string]interface{}{},
Diff: nil,
Err: false,
},
}
for i, tc := range cases {