@@ -735,22 +735,38 @@ func TestWorkflowHandlerRegistration(t *testing.T) {
735735
736736 require .NotNil (t , ctx )
737737
738- wf := func (ctx DBOSContext , input string ) (string , error ) {
739- return input , nil
738+ childWf := func (ctx DBOSContext , input string ) (string , error ) {
739+ return "child-" + input , nil
740+ }
741+
742+ wf := func (ctx DBOSContext , input string ) (WorkflowHandle [string ], error ) {
743+ childHandle , err := RunWorkflow (ctx , childWf , input )
744+ if err != nil {
745+ var emptyHandle WorkflowHandle [string ]
746+ return emptyHandle , err
747+ }
748+ return childHandle , nil
740749 }
741750
751+ RegisterWorkflow (ctx , childWf )
742752 RegisterWorkflow (ctx , wf )
743753
744754 // Launch a workflow
745755 err = Launch (ctx )
746756 require .NoError (t , err )
747757 defer Shutdown (ctx , 1 * time .Minute )
748758
749- // Run a workflow
750- handle , err := RunWorkflow (ctx , wf , "test-input" )
759+ parentHandle , err := RunWorkflow (ctx , wf , "test-input" )
751760 require .NoError (t , err )
752761
753- result , err := handle .GetResult ()
754- require .NoError (t , err , "failed to get result from workflow" )
755- assert .Equal (t , "test-input" , result )
762+ // The result of the parent workflow should itself be a workflow handle
763+ childHandle , err := parentHandle .GetResult ()
764+ require .NoError (t , err , "failed to get child handle from parent workflow" )
765+
766+ // Now we can use the child handle to get the final result
767+ result , err := childHandle .GetResult ()
768+ require .NoError (t , err , "failed to get result from child workflow" )
769+
770+ // Assert final child workflow result
771+ assert .Equal (t , "child-test-input" , result )
756772}
0 commit comments