From 193d4b868ccbd8174d962a863631b96f597c6e00 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 14 Jul 2017 13:50:26 -0400 Subject: [PATCH] backend state tests must honor lineage Remote state implementations may initialize a lineage when creating a new named state (i.e. "workspace"). The tests were ignoring that initial lineage to write a new state to the backend. --- backend/testing.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/testing.go b/backend/testing.go index f8546b309419..feac1c870b0f 100644 --- a/backend/testing.go +++ b/backend/testing.go @@ -92,11 +92,20 @@ func testBackendStates(t *testing.T, b Backend) { // start with a fresh state, and record the lineage being // written to "bar" barState := terraform.NewState() + + // creating the named state may have created a lineage, so use that if it exists. + if s := bar.State(); s != nil && s.Lineage != "" { + barState.Lineage = s.Lineage + } barLineage := barState.Lineage // the foo lineage should be distinct from bar, and unchanged after // modifying bar fooState := terraform.NewState() + // creating the named state may have created a lineage, so use that if it exists. + if s := foo.State(); s != nil && s.Lineage != "" { + fooState.Lineage = s.Lineage + } fooLineage := fooState.Lineage // write a known state to foo