mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: use separate http.Transports for wsproxy tests (#22292)
- Previously all tests were sharing the global http.Transport meaning on `Close` it would close connections presumed to be idle for other tests. fixes https://github.com/coder/internal/issues/112
This commit is contained in:
@@ -146,8 +146,12 @@ func NewWorkspaceProxyReplica(t *testing.T, coderdAPI *coderd.API, owner *coders
|
||||
|
||||
logger := testutil.Logger(t).With(slog.F("server_url", serverURL.String()))
|
||||
|
||||
// nolint: forcetypeassert // This is a stdlib transport it's unnecessary to type assert especially in tests.
|
||||
wssrv, err := wsproxy.New(ctx, &wsproxy.Options{
|
||||
Logger: logger,
|
||||
Logger: logger,
|
||||
// It's important to ensure each test has its own isolated transport to avoid interfering with other tests
|
||||
// especially in shutdown.
|
||||
HTTPClient: &http.Client{Transport: http.DefaultTransport.(*http.Transport).Clone()},
|
||||
Experiments: options.Experiments,
|
||||
DashboardURL: coderdAPI.AccessURL,
|
||||
AccessURL: accessURL,
|
||||
|
||||
Reference in New Issue
Block a user