@@ -295,6 +295,16 @@ func (wt *workflowTester[TResult]) Execute(args ...interface{}) {
295
295
}
296
296
}
297
297
298
+ // Schedule activities
299
+ for _ , event := range result .ActivityEvents {
300
+ gotNewEvents = true
301
+
302
+ a := event .Attributes .(* history.ActivityScheduledAttributes )
303
+ wt .logger .Debug ("Activity event" , "activity" , a .Name )
304
+
305
+ wt .scheduleActivity (tw .instance , event )
306
+ }
307
+
298
308
for _ , workflowEvent := range result .WorkflowEvents {
299
309
gotNewEvents = true
300
310
wt .logger .Debug ("Workflow event" , "event_type" , workflowEvent .HistoryEvent .Type )
@@ -334,7 +344,8 @@ func (wt *workflowTester[TResult]) Execute(args ...interface{}) {
334
344
default :
335
345
}
336
346
337
- if len (wt .timers ) > 0 {
347
+ // If there are no running activities and timers, skip time
348
+ if wt .runningActivities == 0 && len (wt .timers ) > 0 {
338
349
// Take first timer and execute it
339
350
sort .SliceStable (wt .timers , func (i , j int ) bool {
340
351
return wt .timers [i ].At .Before (wt .timers [j ].At )
@@ -431,8 +442,9 @@ func (wt *workflowTester[TResult]) AssertExpectations(t *testing.T) {
431
442
func (wt * workflowTester [TResult ]) scheduleActivity (wfi * core.WorkflowInstance , event history.Event ) {
432
443
e := event .Attributes .(* history.ActivityScheduledAttributes )
433
444
445
+ atomic .AddInt32 (& wt .runningActivities , 1 )
446
+
434
447
go func () {
435
- atomic .AddInt32 (& wt .runningActivities , 1 )
436
448
defer atomic .AddInt32 (& wt .runningActivities , - 1 )
437
449
438
450
var activityErr error
0 commit comments