diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 3698fe0f41..72adca4bb6 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -3110,6 +3110,36 @@ func TestSchemaMap_Diff(t *testing.T) { Err: true, }, + + // A lot of resources currently depended on using the empty string as a + // nil/unset value. + { + Name: "optional, computed, empty string", + Schema: map[string]*Schema{ + "attr": &Schema{ + Type: TypeString, + Optional: true, + Computed: true, + }, + }, + + State: &terraform.InstanceState{ + Attributes: map[string]string{ + "attr": "bar", + }, + }, + + // this does necessarily depend on an interpolated value, but this + // is often how it comes about in a configuration, otherwise the + // value would be unset. + Config: map[string]interface{}{ + "attr": "${var.foo}", + }, + + ConfigVariables: map[string]ast.Variable{ + "var.foo": interfaceToVariableSwallowError(""), + }, + }, } for i, tc := range cases {