diff --git a/upstream/upstream_dot_test.go b/upstream/upstream_dot_test.go index ca93bb0ff..0b14f6f2e 100644 --- a/upstream/upstream_dot_test.go +++ b/upstream/upstream_dot_test.go @@ -76,6 +76,8 @@ func TestUpstream_dnsOverTLS_race(t *testing.T) { wg.Wait() } +// TODO(e.burkov, a.garipov): Add to golibs and use here some kind of helper +// for type assertion of interface types. func TestUpstream_dnsOverTLS_poolReconnect(t *testing.T) { srv := startDoTServer(t, func(w dns.ResponseWriter, req *dns.Msg) { resp := respondToTestMessage(req) @@ -119,7 +121,8 @@ func TestUpstream_dnsOverTLS_poolReconnect(t *testing.T) { // Now let's close the pooled connection. conn := p.conns.Get() - usedConn = testutil.RequireTypeAssert[net.Conn](t, conn) + require.Implements(t, (*net.Conn)(nil), conn) + usedConn, _ = conn.(net.Conn) require.NoError(t, usedConn.Close()) @@ -134,7 +137,7 @@ func TestUpstream_dnsOverTLS_poolReconnect(t *testing.T) { // Now assert that the number of connections in the pool is not changed. conn = p.conns.Get() - _ = testutil.RequireTypeAssert[net.Conn](t, conn) + require.Implements(t, (*net.Conn)(nil), conn) require.Nil(t, p.conns.Get()) assert.NotSame(t, usedConn, conn) @@ -174,7 +177,8 @@ func TestUpstream_dnsOverTLS_poolDeadline(t *testing.T) { // Now let's get connection from the pool and use it again. conn := p.conns.Get() - usedConn := testutil.RequireTypeAssert[net.Conn](t, conn) + require.Implements(t, (*net.Conn)(nil), conn) + usedConn := conn.(net.Conn) response, err = p.exchangeWithConn(usedConn, req) require.NoError(t, err) diff --git a/upstream/upstream_dot_windows.go b/upstream/upstream_dot_windows.go index a2349adcf..003b2ec38 100644 --- a/upstream/upstream_dot_windows.go +++ b/upstream/upstream_dot_windows.go @@ -7,7 +7,7 @@ import ( "golang.org/x/sys/windows" ) -// isConnBroken always returns false. +// isConnBroken returns true if err means that a connection is broken. func isConnBroken(err error) (ok bool) { return errors.Is(err, windows.WSAECONNABORTED) }