Skip to content

Commit

Permalink
mod
Browse files Browse the repository at this point in the history
  • Loading branch information
RyougiNevermore committed Nov 19, 2024
1 parent 65cce4e commit dd03fa3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions async/composite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package async_test
import (
"context"
"github.com/brickingsoft/rxp/async"
"sync"
"testing"
)

Expand All @@ -15,6 +16,8 @@ func TestComposite(t *testing.T) {
}
}()

wg := new(sync.WaitGroup)

promises := make([]async.Promise[int], 0, 1)
for i := 0; i < 10; i++ {
promise, ok := async.TryPromise[int](ctx)
Expand All @@ -26,6 +29,8 @@ func TestComposite(t *testing.T) {
}

composite := async.Composite[[]async.Result[int]](ctx, promises)

wg.Add(1)
composite.OnComplete(func(ctx context.Context, results []async.Result[int], err error) {
nn := make([]int, 0, 1)
ee := make([]error, 0, 1)
Expand All @@ -37,10 +42,13 @@ func TestComposite(t *testing.T) {
}
}
t.Log("composite future:", nn, ee)
wg.Done()
})

for i, promise := range promises {
promise.Succeed(i)
}

wg.Wait()

}

0 comments on commit dd03fa3

Please sign in to comment.