@@ -23,10 +23,16 @@ func TestBasicSessionStore(t *testing.T) {
23
23
_ = db .Close ()
24
24
})
25
25
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.
27
30
s1 := newSession (t , db , clock , "session 1" )
31
+ clock .SetTime (testTime .Add (time .Second ))
28
32
s2 := newSession (t , db , clock , "session 2" )
33
+ clock .SetTime (testTime .Add (2 * time .Second ))
29
34
s3 := newSession (t , db , clock , "session 3" )
35
+ clock .SetTime (testTime .Add (3 * time .Second ))
30
36
s4 := newSession (t , db , clock , "session 4" )
31
37
32
38
// Persist session 1. This should now succeed.
@@ -50,6 +56,14 @@ func TestBasicSessionStore(t *testing.T) {
50
56
require .NoError (t , db .CreateSession (s2 ))
51
57
require .NoError (t , db .CreateSession (s3 ))
52
58
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
+
53
67
// Ensure that we can retrieve each session by both its local pub key
54
68
// and by its ID.
55
69
for _ , s := range []* Session {s1 , s2 , s3 } {
0 commit comments