@@ -395,6 +395,77 @@ func TestWorkflowUpdateOrder(t *testing.T) {
395
395
require .Equal (t , 1 , result )
396
396
}
397
397
398
+ func TestWorkflowUpdateOrderWithOneArg (t * testing.T ) {
399
+ var suite WorkflowTestSuite
400
+ // Test UpdateWorkflowByID works with custom ID and additional arguments
401
+ env := suite .NewTestWorkflowEnvironment ()
402
+ env .RegisterDelayedCallback (func () {
403
+ env .UpdateWorkflowNoRejection ("update" , "id" , t , "args" )
404
+ }, 0 )
405
+
406
+ env .ExecuteWorkflow (func (ctx Context ) (int , error ) {
407
+ var inflightUpdates int
408
+ var ranUpdates int
409
+ err := SetUpdateHandler (ctx , "update" , func (ctx Context , args string ) error {
410
+ inflightUpdates ++
411
+ ranUpdates ++
412
+ defer func () {
413
+ inflightUpdates --
414
+ }()
415
+
416
+ require .Equal (t , "args" , args )
417
+
418
+ return Sleep (ctx , time .Hour )
419
+ }, UpdateHandlerOptions {})
420
+ if err != nil {
421
+ return 0 , err
422
+ }
423
+ err = Await (ctx , func () bool { return inflightUpdates == 0 })
424
+ return ranUpdates , err
425
+ })
426
+
427
+ require .NoError (t , env .GetWorkflowError ())
428
+ var result int
429
+ require .NoError (t , env .GetWorkflowResult (& result ))
430
+ require .Equal (t , 1 , result )
431
+ }
432
+
433
+ func TestWorkflowUpdateOrderWithMultiArgs (t * testing.T ) {
434
+ var suite WorkflowTestSuite
435
+ // Test UpdateWorkflowByID works with custom ID and additional arguments
436
+ env := suite .NewTestWorkflowEnvironment ()
437
+ env .RegisterDelayedCallback (func () {
438
+ env .UpdateWorkflowNoRejection ("update" , "id" , t , "args1" , "args2" )
439
+ }, 0 )
440
+
441
+ env .ExecuteWorkflow (func (ctx Context ) (int , error ) {
442
+ var inflightUpdates int
443
+ var ranUpdates int
444
+ err := SetUpdateHandler (ctx , "update" , func (ctx Context , args1 , args2 string ) error {
445
+ inflightUpdates ++
446
+ ranUpdates ++
447
+ defer func () {
448
+ inflightUpdates --
449
+ }()
450
+
451
+ require .Equal (t , args1 , "args1" )
452
+ require .Equal (t , args2 , "args2" )
453
+
454
+ return Sleep (ctx , time .Hour )
455
+ }, UpdateHandlerOptions {})
456
+ if err != nil {
457
+ return 0 , err
458
+ }
459
+ err = Await (ctx , func () bool { return inflightUpdates == 0 })
460
+ return ranUpdates , err
461
+ })
462
+
463
+ require .NoError (t , env .GetWorkflowError ())
464
+ var result int
465
+ require .NoError (t , env .GetWorkflowResult (& result ))
466
+ require .Equal (t , 1 , result )
467
+ }
468
+
398
469
func TestWorkflowUpdateIdGeneration (t * testing.T ) {
399
470
var suite WorkflowTestSuite
400
471
env := suite .NewTestWorkflowEnvironment ()
0 commit comments