Skip to content

Commit

Permalink
backend state tests must honor lineage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jbardin committed Jul 14, 2017
1 parent 8e2ee53 commit 193d4b8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions backend/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 193d4b8

Please sign in to comment.