From 8db60c0c359ccaa77b5b13f23b0dbf15aff0de9a Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 18 Sep 2018 13:53:25 -0700 Subject: [PATCH] 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 . --- terraform/context_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/terraform/context_test.go b/terraform/context_test.go index a81f8ff2a..32b2e5068 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -296,8 +296,12 @@ func testDiffFn( if k == "id" { continue } + old := "" + if s != nil { + old = s.Attributes[k] + } diff.Attributes[k] = &ResourceAttrDiff{ - Old: "", + Old: old, NewComputed: true, } }