From 753f6c6f8e4b4123f160e72ab57bacd2b5b287fe Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 8 Oct 2014 18:25:31 -0700 Subject: [PATCH] helper/schema: fix failing tests --- helper/schema/schema.go | 3 +++ helper/schema/schema_test.go | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 20baf17f6..7d373bd0d 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -620,6 +620,9 @@ func (m schemaMap) diffString( if o != nil && n == nil { removed = true } + if removed && schema.Computed { + return nil + } diff.Attributes[k] = schema.finalizeDiff(&terraform.ResourceAttrDiff{ Old: os, diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 531891271..8190ff2a6 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -864,6 +864,43 @@ func TestSchemaMap_Diff(t *testing.T) { 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{ "config_vars": &Schema{