@@ -12,6 +12,7 @@ import (
1212 "github.com/cschleiden/go-workflows/backend/history"
1313 "github.com/cschleiden/go-workflows/client"
1414 "github.com/cschleiden/go-workflows/core"
15+ "github.com/cschleiden/go-workflows/internal/sync"
1516 internalwf "github.com/cschleiden/go-workflows/internal/workflow"
1617 "github.com/cschleiden/go-workflows/worker"
1718 "github.com/cschleiden/go-workflows/workflow"
@@ -43,6 +44,48 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
4344 require .Equal (t , "hello world" , output )
4445 },
4546 },
47+ {
48+ name : "Workflow_LotsOfActivities" ,
49+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
50+ a := func (ctx context.Context ) (int , error ) {
51+ return 42 , nil
52+ }
53+
54+ wf := func (ctx workflow.Context , msg string ) (string , error ) {
55+ done := 0
56+
57+ y := make ([]workflow.SelectCase , 0 )
58+ for i := 0 ; i < 100 ; i ++ {
59+ var sc workflow.SelectCase
60+ sc = workflow .Await [int ](workflow .ExecuteActivity [int ](ctx , workflow.ActivityOptions {}, a ),
61+ func (ctx sync.Context , f workflow.Future [int ]) {
62+ done ++
63+
64+ // Remove sc from y
65+ for i , v := range y {
66+ if v == sc {
67+ y = append (y [:i ], y [i + 1 :]... )
68+ break
69+ }
70+ }
71+ })
72+ y = append (y , sc )
73+ }
74+
75+ for done < 100 {
76+ workflow .Select (ctx , y ... )
77+ }
78+
79+ return msg + " world" , nil
80+ }
81+ register (t , ctx , w , []interface {}{wf }, []interface {}{a })
82+
83+ output , err := runWorkflowWithResult [string ](t , ctx , c , wf , "hello" )
84+
85+ require .NoError (t , err )
86+ require .Equal (t , "hello world" , output )
87+ },
88+ },
4689 {
4790 name : "SimpleWorkflow_ExpectedHistory" ,
4891 f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
0 commit comments