Skip to content

Commit

Permalink
Refactor client server tests (#37)
Browse files Browse the repository at this point in the history
- remove unused field;
- unlambda;
- omit type declaration.
  • Loading branch information
alexandear authored May 16, 2023
1 parent 13bae83 commit a2b1bec
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions client_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type cstHandler struct{ *testing.T }
type cstServer struct {
*httptest.Server
URL string
t *testing.T
}

const (
Expand Down Expand Up @@ -463,7 +462,7 @@ func TestBadMethod(t *testing.T) {
}))
defer s.Close()

req, err := http.NewRequest(http.MethodPost, s.URL, strings.NewReader(""))
req, err := http.NewRequest(http.MethodPost, s.URL, http.NoBody)
if err != nil {
t.Fatalf("NewRequest returned error %v", err)
}
Expand Down Expand Up @@ -987,11 +986,9 @@ func TestNetDialConnect(t *testing.T) {
tlsClientConfig: nil,
},
{
name: "HTTP server, NetDialContext undefined, shall fallback to NetDial",
server: server,
netDial: func(network, addr string) (net.Conn, error) {
return net.Dial(network, addr)
},
name: "HTTP server, NetDialContext undefined, shall fallback to NetDial",
server: server,
netDial: net.Dial,
netDialContext: nil,
netDialTLSContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
return nil, errors.New("NetDialTLSContext should not be called")
Expand Down Expand Up @@ -1034,11 +1031,9 @@ func TestNetDialConnect(t *testing.T) {
tlsClientConfig: tlsConfig,
},
{
name: "HTTPS server, NetDialTLSContext and NetDialContext undefined, shall fallback to NetDial and do handshake",
server: tlsServer,
netDial: func(network, addr string) (net.Conn, error) {
return net.Dial(network, addr)
},
name: "HTTPS server, NetDialTLSContext and NetDialContext undefined, shall fallback to NetDial and do handshake",
server: tlsServer,
netDial: net.Dial,
netDialContext: nil,
netDialTLSContext: nil,
tlsClientConfig: tlsConfig,
Expand Down Expand Up @@ -1117,7 +1112,7 @@ func TestNextProtos(t *testing.T) {

// Asserts that Dialer.TLSClientConfig.NextProtos contains "h2"
// after the Client.Get call from net/http above.
var containsHTTP2 bool = false
containsHTTP2 := false
for _, proto := range d.TLSClientConfig.NextProtos {
if proto == "h2" {
containsHTTP2 = true
Expand Down

0 comments on commit a2b1bec

Please sign in to comment.