Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes linter issues in testutils package #3480

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/testutils/httpmultibin/httpmultibin.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func GetTLSClientConfig(t testing.TB, srv *httptest.Server) *tls.Config {
RootCAs: certs,
InsecureSkipVerify: false,
Renegotiation: tls.RenegotiateFreelyAsClient,
MinVersion: tls.VersionTLS10,
MinVersion: tls.VersionTLS13,
}
}

Expand All @@ -67,7 +67,8 @@ const httpDomain = "httpbin.local"
// https://golang.org/src/net/http/internal/testcert.go?s=399:410#L10
const httpsDomain = "example.com"

// HTTPMultiBin can be used as a local alternative of httpbin.org. It offers both http and https servers, as well as real domains
// HTTPMultiBin can be used as a local alternative of httpbin.org.
// It offers both http and https servers, as well as real domains
type HTTPMultiBin struct {
Mux *http.ServeMux
ServerHTTP *httptest.Server
Expand Down Expand Up @@ -331,7 +332,7 @@ func NewHTTPMultiBin(t testing.TB) *HTTPMultiBin {
// Initialize the HTTP2 server, with a copy of the https tls config
http2Srv := httptest.NewUnstartedServer(cmux)
http2Srv.EnableHTTP2 = true
http2Srv.TLS = &(*tlsConfig) // copy it
http2Srv.TLS = tlsConfig
http2Srv.TLS.NextProtos = []string{http2.NextProtoTLS}
require.NoError(t, err)
http2Srv.StartTLS()
Expand Down Expand Up @@ -377,24 +378,24 @@ func NewHTTPMultiBin(t testing.TB) *HTTPMultiBin {
Replacer: strings.NewReplacer(
"HTTPBIN_IP_URL", httpSrv.URL,
"HTTPBIN_DOMAIN", httpDomain,
"HTTPBIN_URL", fmt.Sprintf("http://%s:%s", httpDomain, httpURL.Port()),
"WSBIN_URL", fmt.Sprintf("ws://%s:%s", httpDomain, httpURL.Port()),
"HTTPBIN_URL", fmt.Sprintf("http://%s", net.JoinHostPort(httpDomain, httpURL.Port())),
"WSBIN_URL", fmt.Sprintf("ws://%s", net.JoinHostPort(httpDomain, httpURL.Port())),
"HTTPBIN_IP", httpIP.String(),
"HTTPBIN_PORT", httpURL.Port(),
"HTTPSBIN_IP_URL", httpsSrv.URL,
"HTTPSBIN_DOMAIN", httpsDomain,
"HTTPSBIN_URL", fmt.Sprintf("https://%s:%s", httpsDomain, httpsURL.Port()),
"WSSBIN_URL", fmt.Sprintf("wss://%s:%s", httpsDomain, httpsURL.Port()),
"HTTPSBIN_URL", fmt.Sprintf("https://%s", net.JoinHostPort(httpsDomain, httpsURL.Port())),
"WSSBIN_URL", fmt.Sprintf("wss://%s", net.JoinHostPort(httpsDomain, httpsURL.Port())),
"HTTPSBIN_IP", httpsIP.String(),
"HTTPSBIN_PORT", httpsURL.Port(),

"HTTP2BIN_IP_URL", http2Srv.URL,
"HTTP2BIN_DOMAIN", httpsDomain,
"HTTP2BIN_URL", fmt.Sprintf("https://%s:%s", httpsDomain, http2URL.Port()),
"HTTP2BIN_URL", fmt.Sprintf("https://%s", net.JoinHostPort(httpsDomain, http2URL.Port())),
"HTTP2BIN_IP", http2IP.String(),
"HTTP2BIN_PORT", http2URL.Port(),

"GRPCBIN_ADDR", fmt.Sprintf("%s:%s", httpsDomain, http2URL.Port()),
"GRPCBIN_ADDR", net.JoinHostPort(httpsDomain, http2URL.Port()),
),
TLSClientConfig: tlsConfig,
Dialer: dialer,
Expand Down
6 changes: 4 additions & 2 deletions lib/testutils/minirunner/minirunner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package minirunner provides a mock implementation of the lib.Runner
// We use it in tests
package minirunner

import (
Expand Down Expand Up @@ -94,7 +96,7 @@ func (r MiniRunner) GetDefaultGroup() *lib.Group {

// IsExecutable satisfies lib.Runner, but is mocked for MiniRunner since
// it doesn't deal with JS.
func (r MiniRunner) IsExecutable(name string) bool {
func (r MiniRunner) IsExecutable(_ string) bool {
return true
}

Expand All @@ -119,7 +121,7 @@ func (r *MiniRunner) HandleSummary(ctx context.Context, s *lib.Summary) (map[str
if r.HandleSummaryFn != nil {
return r.HandleSummaryFn(ctx, s)
}
return nil, nil
return nil, nil //nolint:nilnil
}

// VU is a mock VU, spawned by a MiniRunner.
Expand Down
1 change: 1 addition & 0 deletions lib/testutils/mockoutput/mockoutput.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package mockoutput implements a mock output for testing purposes.
package mockoutput

import (
Expand Down
1 change: 1 addition & 0 deletions lib/testutils/mockresolver/resolver.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package mockresolver provides a mock implementation of netext.Resolver.
package mockresolver

import (
Expand Down