@@ -23,10 +23,16 @@ func TestBasicSessionStore(t *testing.T) {
2323 _ = db .Close ()
2424 })
2525
26- // Create a few sessions.
26+ // Create a few sessions. We increment the time by one second between
27+ // each session to ensure that the created at time is unique and hence
28+ // that the ListSessions method returns the sessions in a deterministic
29+ // order.
2730 s1 := newSession (t , db , clock , "session 1" )
31+ clock .SetTime (testTime .Add (time .Second ))
2832 s2 := newSession (t , db , clock , "session 2" )
33+ clock .SetTime (testTime .Add (2 * time .Second ))
2934 s3 := newSession (t , db , clock , "session 3" )
35+ clock .SetTime (testTime .Add (3 * time .Second ))
3036 s4 := newSession (t , db , clock , "session 4" )
3137
3238 // Persist session 1. This should now succeed.
@@ -50,6 +56,14 @@ func TestBasicSessionStore(t *testing.T) {
5056 require .NoError (t , db .CreateSession (s2 ))
5157 require .NoError (t , db .CreateSession (s3 ))
5258
59+ // Check that all sessions are returned in ListSessions.
60+ sessions , err := db .ListSessions (nil )
61+ require .NoError (t , err )
62+ require .Equal (t , 3 , len (sessions ))
63+ assertEqualSessions (t , s1 , sessions [0 ])
64+ assertEqualSessions (t , s2 , sessions [1 ])
65+ assertEqualSessions (t , s3 , sessions [2 ])
66+
5367 // Ensure that we can retrieve each session by both its local pub key
5468 // and by its ID.
5569 for _ , s := range []* Session {s1 , s2 , s3 } {
0 commit comments