@@ -44,12 +44,6 @@ func simpleStep(_ context.Context) (string, error) {
4444 return "from step" , nil
4545}
4646
47- func concurrentSimpleWorkflow (dbosCtx DBOSContext , input int ) (int , error ) {
48- return RunAsStep (dbosCtx , func (ctx context.Context ) (int , error ) {
49- return input * 2 , nil
50- })
51- }
52-
5347func simpleStepError (_ context.Context ) (string , error ) {
5448 return "" , fmt .Errorf ("step failure" )
5549}
@@ -808,8 +802,6 @@ func TestChildWorkflow(t *testing.T) {
808802
809803 // Simple child workflow that returns a result
810804 pollingHandleChildWf := func (dbosCtx DBOSContext , input string ) (string , error ) {
811- // Signal the child workflow is started
812- pollingHandleStartEvent .Set ()
813805 // Wait
814806 pollingHandleCompleteEvent .Wait ()
815807 return input + "-result" , nil
@@ -840,6 +832,9 @@ func TestChildWorkflow(t *testing.T) {
840832 }
841833 }
842834
835+ // Signal the child workflow is started
836+ pollingHandleStartEvent .Set ()
837+
843838 result , err := childHandle .GetResult ()
844839 if err != nil {
845840 return "" , fmt .Errorf ("failed to get result from child workflow: %w" , err )
@@ -854,7 +849,7 @@ func TestChildWorkflow(t *testing.T) {
854849 t .Fatalf ("failed to start parent workflow: %v" , err )
855850 }
856851
857- // Wait for the child workflow to start
852+ // Wait for the workflows to start
858853 pollingHandleStartEvent .Wait ()
859854
860855 // Recover pending workflows - this should give us both parent and child handles
@@ -3056,6 +3051,12 @@ func sendRecvSenderWorkflow(ctx DBOSContext, pairID int) (string, error) {
30563051 return "message-sent" , nil
30573052}
30583053
3054+ func concurrentSimpleWorkflow (dbosCtx DBOSContext , input int ) (int , error ) {
3055+ return RunAsStep (dbosCtx , func (ctx context.Context ) (int , error ) {
3056+ return input * 2 , nil
3057+ })
3058+ }
3059+
30593060func TestConcurrentWorkflows (t * testing.T ) {
30603061 dbosCtx := setupDBOS (t , true , true )
30613062 RegisterWorkflow (dbosCtx , concurrentSimpleWorkflow )
@@ -3084,6 +3085,11 @@ func TestConcurrentWorkflows(t *testing.T) {
30843085 errors <- fmt .Errorf ("failed to get result for workflow %d: %w" , input , err )
30853086 return
30863087 }
3088+ expectedResult := input * 2
3089+ if result != expectedResult {
3090+ errors <- fmt .Errorf ("workflow %d: expected result %d, got %d" , input , expectedResult , result )
3091+ return
3092+ }
30873093 results <- result
30883094 }(i )
30893095 }
@@ -3113,13 +3119,6 @@ func TestConcurrentWorkflows(t *testing.T) {
31133119 if resultCount != numGoroutines {
31143120 t .Fatalf ("Expected %d results, got %d" , numGoroutines , resultCount )
31153121 }
3116-
3117- for i := range numGoroutines {
3118- expectedResult := i * 2
3119- if ! receivedResults [expectedResult ] {
3120- t .Errorf ("Expected result %d not found" , expectedResult )
3121- }
3122- }
31233122 })
31243123
31253124 t .Run ("NotificationWorkflows" , func (t * testing.T ) {
0 commit comments