@@ -16,14 +16,10 @@ var testTime = time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
1616func TestBasicSessionStore (t * testing.T ) {
1717 // Set up a new DB.
1818 clock := clock .NewTestClock (testTime )
19- db , err := NewDB (t .TempDir (), "test.db" , clock )
20- require .NoError (t , err )
21- t .Cleanup (func () {
22- _ = db .Close ()
23- })
19+ db := NewTestDB (t , clock )
2420
2521 // Try fetch a session that doesn't exist yet.
26- _ , err = db .GetSessionByID (ID {1 , 3 , 4 , 4 })
22+ _ , err : = db .GetSessionByID (ID {1 , 3 , 4 , 4 })
2723 require .ErrorIs (t , err , ErrSessionNotFound )
2824
2925 // Reserve a session. This should succeed.
@@ -201,11 +197,7 @@ func TestLinkingSessions(t *testing.T) {
201197
202198 // Set up a new DB.
203199 clock := clock .NewTestClock (testTime )
204- db , err := NewDB (t .TempDir (), "test.db" , clock )
205- require .NoError (t , err )
206- t .Cleanup (func () {
207- _ = db .Close ()
208- })
200+ db := NewTestDB (t , clock )
209201
210202 groupID , err := IDFromBytes ([]byte {1 , 2 , 3 , 4 })
211203 require .NoError (t , err )
@@ -242,11 +234,7 @@ func TestLinkedSessions(t *testing.T) {
242234
243235 // Set up a new DB.
244236 clock := clock .NewTestClock (testTime )
245- db , err := NewDB (t .TempDir (), "test.db" , clock )
246- require .NoError (t , err )
247- t .Cleanup (func () {
248- _ = db .Close ()
249- })
237+ db := NewTestDB (t , clock )
250238
251239 // Create a few sessions. The first one is a new session and the two
252240 // after are all linked to the prior one. All these sessions belong to
@@ -298,18 +286,14 @@ func TestLinkedSessions(t *testing.T) {
298286func TestStateShift (t * testing.T ) {
299287 // Set up a new DB.
300288 clock := clock .NewTestClock (testTime )
301- db , err := NewDB (t .TempDir (), "test.db" , clock )
302- require .NoError (t , err )
303- t .Cleanup (func () {
304- _ = db .Close ()
305- })
289+ db := NewTestDB (t , clock )
306290
307291 // Add a new session to the DB.
308292 s1 := createSession (t , db , "label 1" )
309293
310294 // Check that the session is in the StateCreated state. Also check that
311295 // the "RevokedAt" time has not yet been set.
312- s1 , err = db .GetSession (s1 .LocalPublicKey )
296+ s1 , err : = db .GetSession (s1 .LocalPublicKey )
313297 require .NoError (t , err )
314298 require .Equal (t , StateCreated , s1 .State )
315299 require .Equal (t , time.Time {}, s1 .RevokedAt )
0 commit comments