core: testDiffFn must properly populate "Old" in computed attr diff

When applying a diff to a value we verify that the "old" value in diff is
consistent with the given prior value, as a safety check.

The mock must comply with this or else any tests that produce diffs with
computed new values will not pass the safety check.

This change is verified by the now-passing TestContext2Apply_taintDep .
This commit is contained in:
Martin Atkins 2018-09-18 13:53:25 -07:00
parent 42febd5d14
commit 8db60c0c35
1 changed files with 5 additions and 1 deletions

View File

@ -296,8 +296,12 @@ func testDiffFn(
if k == "id" { if k == "id" {
continue continue
} }
old := ""
if s != nil {
old = s.Attributes[k]
}
diff.Attributes[k] = &ResourceAttrDiff{ diff.Attributes[k] = &ResourceAttrDiff{
Old: "", Old: old,
NewComputed: true, NewComputed: true,
} }
} }