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:
Zach
2025-10-02 11:43:13 -06:00
committed by GitHub
parent 0d2ccacacd
commit 4d1003eace
18 changed files with 59 additions and 33 deletions
+1 -1
View File
@@ -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,
})
+2 -1
View File
@@ -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)