mirror of
https://github.com/coder/coder.git
synced 2026-10-29 17:44:33 +08:00
fix: remove initial global HTTP client usage (#20128)
This PR makes the initial steps at removing usage of the global Go HTTP client, which was seen to have impacts on test flakiness in https://github.com/coder/internal/issues/1020. The first commit removes uses from tests, with the exception of one test that is tightly coupled to the default client. The second commit makes easy/low-risk removals from application code. This should have some impact to reduce test flakiness.
This commit is contained in:
@@ -55,7 +55,7 @@ func TestAccessURL(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
report.Run(ctx, &healthcheck.AccessURLReportOptions{
|
||||
Client: nil, // defaults to http.DefaultClient
|
||||
Client: &http.Client{},
|
||||
AccessURL: nil,
|
||||
})
|
||||
|
||||
|
||||
@@ -511,7 +511,8 @@ func tsDERPMap(ctx context.Context, t testing.TB) *tailcfg.DERPMap {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", ipn.DefaultControlURL+"/derpmap/default", nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := http.DefaultClient.Do(req)
|
||||
client := &http.Client{}
|
||||
res, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer res.Body.Close()
|
||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||
|
||||
Reference in New Issue
Block a user