Этот коммит содержится в:
Christopher Speller
2017-07-20 15:22:49 -07:00
коммит произвёл GitHub
родитель e2f4492ead
Коммит 58839cefb5
624 изменённых файлов: 103449 добавлений и 14954 удалений

31
vendor/github.com/miekg/dns/client_test.go сгенерированный поставляемый
Просмотреть файл

@@ -1,6 +1,7 @@
package dns
import (
"context"
"crypto/tls"
"fmt"
"net"
@@ -249,6 +250,9 @@ func TestClientConn(t *testing.T) {
t.Errorf("failed to exchange: %v", err)
}
r, err := cn.ReadMsg()
if err != nil {
t.Errorf("failed to get a valid answer: %v", err)
}
if r == nil || r.Rcode != RcodeSuccess {
t.Errorf("failed to get an valid answer\n%v", r)
}
@@ -262,6 +266,9 @@ func TestClientConn(t *testing.T) {
if buf == nil {
t.Errorf("failed to get an valid answer\n%v", r)
}
if err != nil {
t.Errorf("failed to get a valid answer: %v", err)
}
if int(h.Bits&0xF) != RcodeSuccess {
t.Errorf("failed to get an valid answer in ReadMsgHeader\n%v", r)
}
@@ -423,7 +430,7 @@ func TestTimeout(t *testing.T) {
// Use a channel + timeout to ensure we don't get stuck if the
// Client Timeout is not working properly
done := make(chan struct{})
done := make(chan struct{}, 2)
timeout := time.Millisecond
allowable := timeout + (10 * time.Millisecond)
@@ -435,14 +442,28 @@ func TestTimeout(t *testing.T) {
c := &Client{Timeout: timeout}
_, _, err := c.Exchange(m, addrstr)
if err == nil {
t.Error("no timeout using Client")
t.Error("no timeout using Client.Exchange")
}
done <- struct{}{}
}()
select {
case <-done:
case <-time.After(abortAfter):
go func() {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
c := &Client{}
_, _, err := c.ExchangeContext(ctx, m, addrstr)
if err == nil {
t.Error("no timeout using Client.ExchangeContext")
}
done <- struct{}{}
}()
// Wait for both the Exchange and ExchangeContext tests to be done.
for i := 0; i < 2; i++ {
select {
case <-done:
case <-time.After(abortAfter):
}
}
length := time.Since(start)