@@ -350,6 +350,7 @@ func TestListActions(t *testing.T) {
350
350
func TestListGroupActions (t * testing.T ) {
351
351
t .Parallel ()
352
352
ctx := context .Background ()
353
+ clock := clock .NewTestClock (testTime1 )
353
354
354
355
group1 := intToSessionID (0 )
355
356
@@ -358,9 +359,7 @@ func TestListGroupActions(t *testing.T) {
358
359
index .AddPair (sessionID1 , group1 )
359
360
index .AddPair (sessionID2 , group1 )
360
361
361
- db , err := NewBoltDB (
362
- t .TempDir (), "test.db" , index , clock .NewDefaultClock (),
363
- )
362
+ db , err := NewBoltDB (t .TempDir (), "test.db" , index , clock )
364
363
require .NoError (t , err )
365
364
t .Cleanup (func () {
366
365
_ = db .Close ()
@@ -372,14 +371,18 @@ func TestListGroupActions(t *testing.T) {
372
371
require .Empty (t , al )
373
372
374
373
// Add an action under session 1.
375
- _ , err = db .AddAction (ctx , action1Req )
374
+ locator1 , err := db .AddAction (ctx , action1Req )
375
+ require .NoError (t , err )
376
+ err = db .SetActionState (ctx , locator1 , ActionStateDone , "" )
376
377
require .NoError (t , err )
377
378
378
379
// There should now be one action in the group.
379
380
al , _ , _ , err = db .ListActions (ctx , nil , WithActionGroupID (group1 ))
380
381
require .NoError (t , err )
381
382
require .Len (t , al , 1 )
382
- require .Equal (t , sessionID1 , al [0 ].SessionID )
383
+ assertEqualActions (t , action1 , al [0 ])
384
+
385
+ clock .SetTime (testTime2 )
383
386
384
387
// Add an action under session 2.
385
388
_ , err = db .AddAction (ctx , action2Req )
@@ -389,8 +392,8 @@ func TestListGroupActions(t *testing.T) {
389
392
al , _ , _ , err = db .ListActions (ctx , nil , WithActionGroupID (group1 ))
390
393
require .NoError (t , err )
391
394
require .Len (t , al , 2 )
392
- require . Equal (t , sessionID1 , al [0 ]. SessionID )
393
- require . Equal (t , sessionID2 , al [1 ]. SessionID )
395
+ assertEqualActions (t , action1 , al [0 ])
396
+ assertEqualActions (t , action2 , al [1 ])
394
397
}
395
398
396
399
func assertEqualActions (t * testing.T , expected , got * Action ) {
0 commit comments