github.com/lingyao2333/mo-zero@v1.4.1/core/fx/parallel_test.go (about) 1 package fx 2 3 import ( 4 "sync/atomic" 5 "testing" 6 "time" 7 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestParallel(t *testing.T) { 12 var count int32 13 Parallel(func() { 14 time.Sleep(time.Millisecond * 100) 15 atomic.AddInt32(&count, 1) 16 }, func() { 17 time.Sleep(time.Millisecond * 100) 18 atomic.AddInt32(&count, 2) 19 }, func() { 20 time.Sleep(time.Millisecond * 100) 21 atomic.AddInt32(&count, 3) 22 }) 23 assert.Equal(t, int32(6), count) 24 }