helper/schema: fix failing tests

/cc @svanharmelen - I think some logic changed after my refactor. I now
return Exists: true when Computed: true but the value might be blank to
note that the FieldReader FOUND a value, its just unknown. I think
before it didn't do that so the logic for GetOk has to be "does it exist
and is it _not_ computed"

Seems weird because I just realized there is no way to get the OLD value
of something if it is being computed now, but I looked and there are
tests that verify this and they're like... test #5 of Get. So, they're
not new meaning that must've been expected behavior? Hm. Let me know if
you find any other issues from acceptance tests
This commit is contained in:
Mitchell Hashimoto 2015-01-14 15:35:40 -08:00
parent 05de36b4ea
commit db02541d31
2 changed files with 2 additions and 4 deletions

View File

@ -91,7 +91,7 @@ func (d *ResourceData) GetChange(key string) (interface{}, interface{}) {
// The second result should be checked to determine this information.
func (d *ResourceData) GetOk(key string) (interface{}, bool) {
r := d.getRaw(key, getSourceSet)
return r.Value, r.Exists
return r.Value, r.Exists && !r.Computed
}
func (d *ResourceData) getRaw(key string, level getSource) getResult {

View File

@ -868,7 +868,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Diff: &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"ports.#": &terraform.ResourceAttrDiff{
Old: "0",
Old: "",
New: "",
NewComputed: true,
},
@ -1560,7 +1560,6 @@ func TestSchemaMap_Diff(t *testing.T) {
Diff: &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"instances.#": &terraform.ResourceAttrDiff{
Old: "0",
NewComputed: true,
},
},
@ -1688,7 +1687,6 @@ func TestSchemaMap_Diff(t *testing.T) {
New: "1",
},
"route.~1.gateway.#": &terraform.ResourceAttrDiff{
Old: "0",
NewComputed: true,
},
},