aboutsummaryrefslogtreecommitdiff
path: root/client_test.go
diff options
context:
space:
mode:
authorGravatar fare83 <86996242+fare83@users.noreply.github.com> 2022-07-06 20:03:50 +0800
committerGravatar GitHub <noreply@github.com> 2022-07-06 14:03:50 +0200
commitc94be05897cb48e1fb4ab4d15343cc055b8c1166 (patch)
tree0e3b97533278954dcc4418476d0f513202f87e0a /client_test.go
parentClose new connections after 5s in closeIdleConns (diff)
downloadfasthttp-c94be05897cb48e1fb4ab4d15343cc055b8c1166.tar.gz
fasthttp-c94be05897cb48e1fb4ab4d15343cc055b8c1166.tar.bz2
fasthttp-c94be05897cb48e1fb4ab4d15343cc055b8c1166.zip
use timeout insteadof read/writetimeout when timeout lower than read/… (#1336)
* use timeout insteadof read/writetimeout when timeout lower than read/writetimeout * use deadtime; fix test timeout; Co-authored-by: 徐焱 <xuyan4@staff.sina.com.cn>
Diffstat (limited to 'client_test.go')
-rw-r--r--client_test.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/client_test.go b/client_test.go
index cd0e49c..faf29d4 100644
--- a/client_test.go
+++ b/client_test.go
@@ -1635,9 +1635,13 @@ func TestClientDoTimeoutSuccessConcurrent(t *testing.T) {
func TestClientGetTimeoutError(t *testing.T) {
t.Parallel()
+ s := startEchoServer(t, "tcp", "127.0.0.1:")
+ defer s.Stop()
+
+ testConn, _ := net.Dial("tcp", s.ln.Addr().String())
c := &Client{
Dial: func(addr string) (net.Conn, error) {
- return &readTimeoutConn{t: time.Second}, nil
+ return &readTimeoutConn{Conn: testConn, t: time.Second}, nil
},
}
@@ -1647,9 +1651,13 @@ func TestClientGetTimeoutError(t *testing.T) {
func TestClientGetTimeoutErrorConcurrent(t *testing.T) {
t.Parallel()
+ s := startEchoServer(t, "tcp", "127.0.0.1:")
+ defer s.Stop()
+
+ testConn, _ := net.Dial("tcp", s.ln.Addr().String())
c := &Client{
Dial: func(addr string) (net.Conn, error) {
- return &readTimeoutConn{t: time.Second}, nil
+ return &readTimeoutConn{Conn: testConn, t: time.Second}, nil
},
MaxConnsPerHost: 1000,
}
@@ -1668,9 +1676,13 @@ func TestClientGetTimeoutErrorConcurrent(t *testing.T) {
func TestClientDoTimeoutError(t *testing.T) {
t.Parallel()
+ s := startEchoServer(t, "tcp", "127.0.0.1:")
+ defer s.Stop()
+
+ testConn, _ := net.Dial("tcp", s.ln.Addr().String())
c := &Client{
Dial: func(addr string) (net.Conn, error) {
- return &readTimeoutConn{t: time.Second}, nil
+ return &readTimeoutConn{Conn: testConn, t: time.Second}, nil
},
}
@@ -1680,9 +1692,13 @@ func TestClientDoTimeoutError(t *testing.T) {
func TestClientDoTimeoutErrorConcurrent(t *testing.T) {
t.Parallel()
+ s := startEchoServer(t, "tcp", "127.0.0.1:")
+ defer s.Stop()
+
+ testConn, _ := net.Dial("tcp", s.ln.Addr().String())
c := &Client{
Dial: func(addr string) (net.Conn, error) {
- return &readTimeoutConn{t: time.Second}, nil
+ return &readTimeoutConn{Conn: testConn, t: time.Second}, nil
},
MaxConnsPerHost: 1000,
}