state/remote: increment serial properly
This commit is contained in:
parent
c2bf600603
commit
ed6128aa6e
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue