diff options
author | Oleksandr Redko <oleksandr.red+github@gmail.com> | 2023-03-14 23:36:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 22:36:38 +0100 |
commit | a281f1d21fed8136ce0b8160488464edf1ae885b (patch) | |
tree | fdb8720ef8de1873324df5e7108c1f3bf04d3f4e /client_test.go | |
parent | client: fix Do hangs when configure host client fails (#1514) (diff) | |
download | fasthttp-a281f1d21fed8136ce0b8160488464edf1ae885b.tar.gz fasthttp-a281f1d21fed8136ce0b8160488464edf1ae885b.tar.bz2 fasthttp-a281f1d21fed8136ce0b8160488464edf1ae885b.zip |
client: HostClient.Do hangs out when ErrConnPoolStrategyNotImpl (#1515)
Diffstat (limited to 'client_test.go')
-rw-r--r-- | client_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/client_test.go b/client_test.go index fc42b2d..a4fe418 100644 --- a/client_test.go +++ b/client_test.go @@ -3048,6 +3048,47 @@ func TestHttpsRequestWithoutParsedURL(t *testing.T) { } } +func TestHostClientErrConnPoolStrategyNotImpl(t *testing.T) { + t.Parallel() + + ln := fasthttputil.NewInmemoryListener() + server := &Server{ + Handler: func(ctx *RequestCtx) {}, + } + serverStopCh := make(chan struct{}) + go func() { + if err := server.Serve(ln); err != nil { + t.Errorf("unexpected error: %v", err) + } + close(serverStopCh) + }() + + client := &HostClient{ + Addr: "foobar", + Dial: func(addr string) (net.Conn, error) { + return ln.Dial() + }, + ConnPoolStrategy: ConnPoolStrategyType(100), + } + + req := AcquireRequest() + req.SetRequestURI("http://foobar/baz") + + if err := client.Do(req, AcquireResponse()); err != nil { + t.Fatalf("unexpected error: %v", err) + } + if err := client.Do(req, &Response{}); err != ErrConnPoolStrategyNotImpl { + t.Errorf("expected ErrConnPoolStrategyNotImpl error, got %v", err) + } + if err := client.Do(req, &Response{}); err != ErrConnPoolStrategyNotImpl { + t.Errorf("expected ErrConnPoolStrategyNotImpl error, got %v", err) + } + + if err := ln.Close(); err != nil { + t.Fatalf("unexpected error: %v", err) + } +} + func Test_AddMissingPort(t *testing.T) { type args struct { addr string |