tests: fix leak in TestDialParseTargetUnknownScheme (#2320)

Do a non-blocking send so if dial is called again in a retry, it won't block forever.
This commit is contained in:
Menghan Li
2018-09-27 13:50:06 -07:00
committed by GitHub
parent a338994886
commit f8063d3b62

View File

@ -97,8 +97,11 @@ func TestDialParseTargetUnknownScheme(t *testing.T) {
{"passthrough://a.server.com/google.com", "google.com"},
} {
dialStrCh := make(chan string, 1)
cc, err := Dial(test.targetStr, WithInsecure(), WithDialer(func(t string, _ time.Duration) (net.Conn, error) {
dialStrCh <- t
cc, err := Dial(test.targetStr, WithInsecure(), WithDialer(func(addr string, _ time.Duration) (net.Conn, error) {
select {
case dialStrCh <- addr:
default:
}
return nil, fmt.Errorf("test dialer, always error")
}))
if err != nil {