diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-07-20 15:22:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-20 15:22:49 -0700 |
commit | 58839cefb50e56ae5b157b37e9814ae83ceee70b (patch) | |
tree | 5de966481678096fc9567f74f96673b34a65127c /vendor/github.com/miekg/dns/client_test.go | |
parent | e2f4492eadb5d3c58606b1fdd5774b63a07c236a (diff) | |
download | chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.gz chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.bz2 chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.zip |
Upgrading server dependancies (#6984)
Diffstat (limited to 'vendor/github.com/miekg/dns/client_test.go')
-rw-r--r-- | vendor/github.com/miekg/dns/client_test.go | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/vendor/github.com/miekg/dns/client_test.go b/vendor/github.com/miekg/dns/client_test.go index dee585f36..73083dbaf 100644 --- a/vendor/github.com/miekg/dns/client_test.go +++ b/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{}{} + }() + + 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{}{} }() - select { - case <-done: - case <-time.After(abortAfter): + // 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) |