@@ -30,21 +30,26 @@ func (l *lbBalancingClient) DoDeadline(req *fasthttp.Request, resp *fasthttp.Res
3030 return l .client .DoDeadline (req , resp , deadline )
3131}
3232
33- func (l * lbBalancingClient ) PendingRequests () int { return 0 }
33+ func (* lbBalancingClient ) PendingRequests () int { return 0 }
3434
3535func (l * lbBalancingClient ) LBClient () * fasthttp.LBClient { return l .client }
3636
3737type stubRedirectCall struct {
38- status int
39- location string
4038 err error
39+ status * int
40+ location * string
4141}
4242
43+ func ptrInt (v int ) * int { return & v }
44+
45+ func ptrString (v string ) * string { return & v }
46+
4347type stubRedirectClient struct {
4448 calls []stubRedirectCall
4549}
4650
4751func (s * stubRedirectClient ) Do (req * fasthttp.Request , resp * fasthttp.Response ) error {
52+ _ = req
4853 if len (s .calls ) == 0 {
4954 resp .Reset ()
5055 resp .Header .SetStatusCode (fasthttp .StatusOK )
@@ -55,11 +60,11 @@ func (s *stubRedirectClient) Do(req *fasthttp.Request, resp *fasthttp.Response)
5560 s .calls = s .calls [1 :]
5661
5762 resp .Reset ()
58- if call .status != 0 {
59- resp .Header .SetStatusCode (call .status )
63+ if call .status != nil {
64+ resp .Header .SetStatusCode (* call .status )
6065 }
61- if call .location != "" {
62- resp .Header .Set ("Location" , call .location )
66+ if call .location != nil {
67+ resp .Header .Set ("Location" , * call .location )
6368 }
6469 return call .err
6570}
@@ -70,6 +75,7 @@ func TestStandardClientTransportCoverage(t *testing.T) {
7075 var dialCount atomic.Int32
7176 client := & fasthttp.Client {}
7277 client .Dial = func (addr string ) (net.Conn , error ) {
78+ _ = addr
7379 dialCount .Add (1 )
7480 return nil , errors .New ("dial error" )
7581 }
@@ -124,14 +130,16 @@ func TestLBClientTransportAccessorsAndOverrides(t *testing.T) {
124130
125131 hostWithoutOverrides := & fasthttp.HostClient {Addr : "example.com:80" }
126132 nestedDialHost := & fasthttp.HostClient {Addr : "example.org:80" }
127- nestedTLSHost := & fasthttp.HostClient {Addr : "example.net:80" , TLSConfig : & tls.Config {ServerName : "example" }}
133+ nestedTLSHost := & fasthttp.HostClient {Addr : "example.net:80" , TLSConfig : & tls.Config {ServerName : "example" , MinVersion : tls . VersionTLS12 }}
128134 multiLevelHost := & fasthttp.HostClient {Addr : "example.edu:80" }
129135
130136 nestedDialHost .Dial = func (addr string ) (net.Conn , error ) {
137+ _ = addr
131138 return nil , errors .New ("original dial" )
132139 }
133140
134141 multiLevelHost .Dial = func (addr string ) (net.Conn , error ) {
142+ _ = addr
135143 return nil , errors .New ("multi-level dial" )
136144 }
137145
@@ -148,7 +156,7 @@ func TestLBClientTransportAccessorsAndOverrides(t *testing.T) {
148156 require .Equal (t , nestedTLSHost .TLSConfig , transport .TLSConfig ())
149157 require .NotNil (t , transport .dial )
150158
151- overrideTLS := & tls.Config {ServerName : "override" }
159+ overrideTLS := & tls.Config {ServerName : "override" , MinVersion : tls . VersionTLS12 }
152160 transport .SetTLSConfig (overrideTLS )
153161 require .Equal (t , overrideTLS , hostWithoutOverrides .TLSConfig )
154162 require .Equal (t , overrideTLS , nestedDialHost .TLSConfig )
@@ -158,6 +166,7 @@ func TestLBClientTransportAccessorsAndOverrides(t *testing.T) {
158166
159167 overrideDialCalled := atomic.Bool {}
160168 overrideDial := func (addr string ) (net.Conn , error ) {
169+ _ = addr
161170 overrideDialCalled .Store (true )
162171 return nil , errors .New ("override dial" )
163172 }
@@ -191,10 +200,10 @@ func TestExtractTLSConfigVariations(t *testing.T) {
191200 require .Nil (t , extractTLSConfig (nil ))
192201 require .Nil (t , extractTLSConfig ([]fasthttp.BalancingClient {stubBalancingClient {}}))
193202
194- host := & fasthttp.HostClient {TLSConfig : & tls.Config {ServerName : "configured" }}
203+ host := & fasthttp.HostClient {TLSConfig : & tls.Config {ServerName : "configured" , MinVersion : tls . VersionTLS12 }}
195204 require .Equal (t , host .TLSConfig , extractTLSConfig ([]fasthttp.BalancingClient {host }))
196205
197- nested := & fasthttp.HostClient {TLSConfig : & tls.Config {ServerName : "nested" }}
206+ nested := & fasthttp.HostClient {TLSConfig : & tls.Config {ServerName : "nested" , MinVersion : tls . VersionTLS12 }}
198207 nestedLB := & lbBalancingClient {client : & fasthttp.LBClient {Clients : []fasthttp.BalancingClient {nested }}}
199208 require .Equal (t , nested .TLSConfig , extractTLSConfig ([]fasthttp.BalancingClient {nestedLB }))
200209
@@ -212,6 +221,7 @@ func TestExtractDialVariations(t *testing.T) {
212221 hostWithDial := & fasthttp.HostClient {}
213222 called := atomic.Bool {}
214223 hostWithDial .Dial = func (addr string ) (net.Conn , error ) {
224+ _ = addr
215225 called .Store (true )
216226 return nil , errors .New ("dial" )
217227 }
@@ -225,6 +235,7 @@ func TestExtractDialVariations(t *testing.T) {
225235 nestedHost := & fasthttp.HostClient {}
226236 nestedCalled := atomic.Bool {}
227237 nestedHost .Dial = func (addr string ) (net.Conn , error ) {
238+ _ = addr
228239 nestedCalled .Store (true )
229240 return nil , errors .New ("nested dial" )
230241 }
@@ -238,6 +249,7 @@ func TestExtractDialVariations(t *testing.T) {
238249 multiNestedHost := & fasthttp.HostClient {}
239250 multiCalled := atomic.Bool {}
240251 multiNestedHost .Dial = func (addr string ) (net.Conn , error ) {
252+ _ = addr
241253 multiCalled .Store (true )
242254 return nil , errors .New ("multi nested dial" )
243255 }
@@ -283,20 +295,20 @@ func TestDoRedirectsWithClientBranches(t *testing.T) {
283295
284296 req .SetRequestURI ("http://example.com/start" )
285297
286- client := & stubRedirectClient {calls : []stubRedirectCall {{status : fasthttp .StatusMovedPermanently , location : "/next" }}}
298+ client := & stubRedirectClient {calls : []stubRedirectCall {{status : ptrInt ( fasthttp .StatusMovedPermanently ) , location : ptrString ( "/next" ) }}}
287299 require .ErrorIs (t , doRedirectsWithClient (req , resp , - 1 , client ), fasthttp .ErrTooManyRedirects )
288300
289301 req .Header .SetMethod (fasthttp .MethodPost )
290302 req .SetRequestURI ("http://example.com/start" )
291- client = & stubRedirectClient {calls : []stubRedirectCall {{status : fasthttp .StatusFound }}}
303+ client = & stubRedirectClient {calls : []stubRedirectCall {{status : ptrInt ( fasthttp .StatusFound ) }}}
292304 require .ErrorIs (t , doRedirectsWithClient (req , resp , 1 , client ), fasthttp .ErrMissingLocation )
293305
294306 req .Header .SetMethod (fasthttp .MethodPost )
295307 req .SetRequestURI ("http://example.com/start" )
296308 req .SetBodyString ("payload" )
297- client = & stubRedirectClient {calls : []stubRedirectCall {{status : fasthttp .StatusMovedPermanently , location : "/redirect" }, {status : fasthttp .StatusOK }}}
309+ client = & stubRedirectClient {calls : []stubRedirectCall {{status : ptrInt ( fasthttp .StatusMovedPermanently ) , location : ptrString ( "/redirect" ) }, {status : ptrInt ( fasthttp .StatusOK ) }}}
298310 require .NoError (t , doRedirectsWithClient (req , resp , 1 , client ))
299311 require .Equal (t , fasthttp .MethodGet , string (req .Header .Method ()))
300312 require .Equal (t , "http://example.com/redirect" , req .URI ().String ())
301- require .Len (t , req .Body (), 0 )
313+ require .Empty (t , req .Body ())
302314}
0 commit comments