Fix(picker): add WithTimeout for some situation

This commit is contained in:
Dreamacro
2019-07-18 00:12:01 +08:00
parent 0670275533
commit f00dfdd34d
5 changed files with 22 additions and 9 deletions

View File

@ -30,9 +30,9 @@ func TestPicker_Basic(t *testing.T) {
}
func TestPicker_Timeout(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*5)
picker, ctx, cancel := WithTimeout(context.Background(), time.Millisecond*5)
defer cancel()
picker, ctx := WithContext(ctx)
picker.Go(sleepAndSend(ctx, 20, 1))
number := picker.Wait()