fix(netxlite/dns): more stricly mirror stdlib error strings (#513)
This diff attempts to modify the errors reported by our custom resolver by matching more strings from the stdlib. Part of https://github.com/ooni/probe/issues/1733 and diff has been extracted from https://github.com/ooni/probe-cli/pull/506.
This commit is contained in:
parent
201f602a40
commit
24b230fd38
17 changed files with 177 additions and 52 deletions
|
|
@ -5,7 +5,6 @@ import (
|
|||
"crypto/tls"
|
||||
"errors"
|
||||
"net"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
|
|
@ -79,8 +78,8 @@ func TestOONIWithEmptyReply(t *testing.T) {
|
|||
}
|
||||
r := NewSerialResolver(txp)
|
||||
addrs, err := r.LookupHost(context.Background(), "www.gogle.com")
|
||||
if err == nil || !strings.HasSuffix(err.Error(), "no response returned") {
|
||||
t.Fatal("not the error we expected")
|
||||
if !errors.Is(err, errorsx.ErrOODNSNoAnswer) {
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
if addrs != nil {
|
||||
t.Fatal("expected nil address here")
|
||||
|
|
@ -146,3 +145,18 @@ func TestOONIWithTimeout(t *testing.T) {
|
|||
t.Fatal("we didn't actually take the timeouts")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSerialResolverCloseIdleConnections(t *testing.T) {
|
||||
var called bool
|
||||
r := &SerialResolver{
|
||||
Txp: &mocks.RoundTripper{
|
||||
MockCloseIdleConnections: func() {
|
||||
called = true
|
||||
},
|
||||
},
|
||||
}
|
||||
r.CloseIdleConnections()
|
||||
if !called {
|
||||
t.Fatal("not called")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue