From b510d2654c7f83d24bbbb78aa3f79b48f097ae0e Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sun, 27 Oct 2024 12:10:51 +0100 Subject: [PATCH] Handle timeout errors in test client cleanup Added a check in the client cleanup function to skip the test if the client connection fails due to a timeout. This ensures that network-related timeouts do not cause test failures, providing more reliable test outcomes. --- client_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client_test.go b/client_test.go index 70032ba..cebadc5 100644 --- a/client_test.go +++ b/client_test.go @@ -2579,6 +2579,10 @@ func TestClient_Send(t *testing.T) { } t.Cleanup(func() { if err := client.Close(); err != nil { + var netErr net.Error + if errors.As(err, &netErr) && netErr.Timeout() { + t.Skip("failed to connect to the test server due to timeout") + } t.Errorf("failed to close client: %s", err) } })