File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,12 @@ func seqGroups(ctx context.Context, groups ...[]AsyncFn) error {
9191
9292 tasks := make ([]AsyncFn , 0 , len (groups ))
9393 for _ , group := range groups {
94+ if len (group ) == 0 {
95+ continue
96+ }
97+
9498 validateAsyncFuncs (group ... )
99+
95100 task := func (funcs ... AsyncFn ) AsyncFn {
96101 return func (ctx context.Context ) error {
97102 _ , err := all (ctx , funcs ... )
Original file line number Diff line number Diff line change @@ -125,6 +125,32 @@ func TestSeqGroups(t *testing.T) {
125125 }
126126}
127127
128+ func TestSeqGroupsWithEmptyGroup (t * testing.T ) {
129+ a := assert .New (t )
130+ cnts := make ([]atomic.Int32 , 4 )
131+ groups := make ([][]async.AsyncFn , 0 , 3 )
132+ expectedCnts := []int {2 , 0 , 4 , 5 }
133+
134+ for i := 0 ; i < 4 ; i ++ {
135+ tasks := make ([]async.AsyncFn , 0 )
136+ if i != 1 {
137+ idx := i
138+ for j := 0 ; j < i + 2 ; j ++ {
139+ tasks = append (tasks , func () {
140+ cnts [idx ].Add (1 )
141+ })
142+ }
143+ }
144+ groups = append (groups , tasks )
145+ }
146+
147+ err := async .SeqGroups (groups ... )
148+ a .NilNow (err )
149+ for i := 0 ; i < 3 ; i ++ {
150+ a .EqualNow (cnts [i ].Load (), expectedCnts [i ])
151+ }
152+ }
153+
128154func TestSeqGroupsWithoutTasks (t * testing.T ) {
129155 a := assert .New (t )
130156
You can’t perform that action at this time.
0 commit comments