From 1c3ba3b2f0e3171f7628df03e00d8abf71f30a64 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Tue, 2 Apr 2024 19:00:44 +0300 Subject: [PATCH] test: replace panic with returning error (#1747) --- client_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/client_test.go b/client_test.go index 48429657cc..468d44713d 100644 --- a/client_test.go +++ b/client_test.go @@ -2003,9 +2003,8 @@ func TestClientNonIdempotentRetry(t *testing.T) { s: "HTTP/1.1 345 OK\r\nContent-Type: foobar\r\nContent-Length: 7\r\n\r\n0123456", }, nil default: - t.Fatalf("unexpected number of dials: %d", dialsCount) + return nil, fmt.Errorf("unexpected number of dials: %d", dialsCount) } - panic("unreachable") }, } @@ -2053,9 +2052,8 @@ func TestClientNonIdempotentRetry_BodyStream(t *testing.T) { b: []byte("HTTP/1.1 345 OK\r\nContent-Type: foobar\r\n\r\n"), }, nil default: - t.Fatalf("unexpected number of dials: %d", dialsCount) + return nil, fmt.Errorf("unexpected number of dials: %d", dialsCount) } - panic("unreachable") }, } @@ -2096,9 +2094,8 @@ func TestClientIdempotentRequest(t *testing.T) { s: "HTTP/1.1 345 OK\r\nContent-Type: foobar\r\nContent-Length: 7\r\n\r\n0123456", }, nil default: - t.Fatalf("unexpected number of dials: %d", dialsCount) + return nil, fmt.Errorf("unexpected number of dials: %d", dialsCount) } - panic("unreachable") }, } @@ -2152,9 +2149,8 @@ func TestClientRetryRequestWithCustomDecider(t *testing.T) { s: "HTTP/1.1 345 OK\r\nContent-Type: foobar\r\nContent-Length: 7\r\n\r\n0123456", }, nil default: - t.Fatalf("unexpected number of dials: %d", dialsCount) + return nil, fmt.Errorf("unexpected number of dials: %d", dialsCount) } - panic("unreachable") }, RetryIf: func(req *Request) bool { return req.URI().String() == "http://foobar/a/b"