add another failing test for remote.State lineage

Want to make sure we don't hit this again.
This commit is contained in:
James Bardin 2017-08-01 17:50:53 -04:00
parent 16e8e405c7
commit c3e943bed2
1 changed files with 39 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"github.com/hashicorp/terraform/backend"
"github.com/hashicorp/terraform/state/remote"
"github.com/hashicorp/terraform/terraform"
)
func TestBackend_impl(t *testing.T) {
@ -49,3 +50,41 @@ func TestBackendLocked(t *testing.T) {
backend.TestBackend(t, b1, b2)
}
// use the this backen to test the remote.State implementation
func TestRemoteState(t *testing.T) {
defer Reset()
b := backend.TestBackendConfig(t, New(), nil)
workspace := "workspace"
// create a new workspace in this backend
s, err := b.State(workspace)
if err != nil {
t.Fatal(err)
}
// force overwriting the remote state
newState := terraform.NewState()
if err := s.WriteState(newState); err != nil {
t.Fatal(err)
}
if err := s.PersistState(); err != nil {
t.Fatal(err)
}
if err := s.RefreshState(); err != nil {
t.Fatal(err)
}
savedState := s.State()
if err != nil {
t.Fatal(err)
}
if savedState.Lineage != newState.Lineage {
t.Fatal("saved state has incorrect lineage")
}
}