use assert.AnError consistently in tests (#5066)

No functional change expected.
This commit is contained in:
Marten Seemann
2025-04-21 09:52:08 +08:00
committed by GitHub
parent d35b5ac187
commit b3f55bb7b7
16 changed files with 77 additions and 84 deletions

View File

@@ -26,6 +26,7 @@ import (
"github.com/quic-go/quic-go/http3"
quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -396,14 +397,13 @@ func TestHTTPReestablishConnectionAfterDialError(t *testing.T) {
port := startHTTPServer(t, mux)
var dialCounter int
testErr := errors.New("test error")
cl := http.Client{
Transport: &http3.Transport{
TLSClientConfig: getTLSClientConfig(),
Dial: func(ctx context.Context, addr string, tlsConf *tls.Config, conf *quic.Config) (quic.EarlyConnection, error) {
dialCounter++
if dialCounter == 1 { // make the first dial fail
return nil, testErr
return nil, assert.AnError
}
return quic.DialAddrEarly(ctx, addr, tlsConf, conf)
},
@@ -412,7 +412,7 @@ func TestHTTPReestablishConnectionAfterDialError(t *testing.T) {
defer cl.Transport.(io.Closer).Close()
_, err := cl.Get(fmt.Sprintf("https://localhost:%d/hello", port))
require.ErrorIs(t, err, testErr)
require.ErrorIs(t, err, assert.AnError)
resp, err := cl.Get(fmt.Sprintf("https://localhost:%d/hello", port))
require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.StatusCode)