state/remote: increment serial properly

This commit is contained in:
Mitchell Hashimoto 2015-02-23 21:30:59 -08:00
parent c2bf600603
commit ed6128aa6e
2 changed files with 9 additions and 3 deletions

View File

@ -13,7 +13,7 @@ import (
type State struct {
Client Client
state *terraform.State
state, readState *terraform.State
}
// StateReader impl.
@ -43,11 +43,14 @@ func (s *State) RefreshState() error {
}
s.state = state
s.readState = state
return nil
}
// StatePersister impl.
func (s *State) PersistState() error {
s.state.IncrementSerialMaybe(s.readState)
var buf bytes.Buffer
if err := terraform.WriteState(s.state, &buf); err != nil {
return err

View File

@ -7,8 +7,11 @@ import (
)
func TestState(t *testing.T) {
s := &State{Client: new(InmemClient)}
s.WriteState(state.TestStateInitial())
s := &State{
Client: new(InmemClient),
state: state.TestStateInitial(),
readState: state.TestStateInitial(),
}
if err := s.PersistState(); err != nil {
t.Fatalf("err: %s", err)
}