consul: Testing FSM snapshot of sessions

pull/162/head
Armon Dadgar 2014-05-15 19:57:48 -07:00
parent 555533e2f8
commit aa97e24b02
1 changed files with 11 additions and 0 deletions

View File

@ -326,6 +326,8 @@ func TestFSM_SnapshotRestore(t *testing.T) {
Key: "/test", Key: "/test",
Value: []byte("foo"), Value: []byte("foo"),
}) })
session := &structs.Session{Node: "foo"}
fsm.state.SessionCreate(9, session)
// Snapshot // Snapshot
snap, err := fsm.Snapshot() snap, err := fsm.Snapshot()
@ -383,6 +385,15 @@ func TestFSM_SnapshotRestore(t *testing.T) {
if string(d.Value) != "foo" { if string(d.Value) != "foo" {
t.Fatalf("bad: %v", d) t.Fatalf("bad: %v", d)
} }
// Verify session is restored
_, s, err := fsm.state.SessionGet(session.ID)
if err != nil {
t.Fatalf("err: %v", err)
}
if s.Node != "foo" {
t.Fatalf("bad: %v", d)
}
} }
func TestFSM_KVSSet(t *testing.T) { func TestFSM_KVSSet(t *testing.T) {