package lo import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestAsync(t *testing.T) { is := assert.New(t) sync := make(chan struct{}) ch := Async(func() int { <-sync return 10 }) sync <- struct{}{} select { case result := <-ch: is.Equal(result, 10) case <-time.After(time.Millisecond): is.Fail("Async should not block") } }