@@ -244,7 +244,7 @@ func TestGoFetcherQuery(t *testing.T) {
244244 gf .initOnce .Do (gf .init )
245245 gf .env = append (gf .env , "GOPROXY=" + proxyServer .URL + "/direct/" )
246246
247- version , time , err := gf .Query (context . Background (), tt .path , "latest" )
247+ version , time , err := gf .Query (t . Context (), tt .path , "latest" )
248248 if tt .wantErr != nil {
249249 if err == nil {
250250 t .Fatal ("expected error" )
@@ -338,7 +338,7 @@ func TestGoFetcherProxyQuery(t *testing.T) {
338338 if err != nil {
339339 t .Fatalf ("unexpected error %v" , err )
340340 }
341- version , time , err := gf .proxyQuery (context . Background (), tt .path , tt .query , proxy )
341+ version , time , err := gf .proxyQuery (t . Context (), tt .path , tt .query , proxy )
342342 if tt .wantErr != nil {
343343 if err == nil {
344344 t .Fatal ("expected error" )
@@ -398,7 +398,7 @@ func TestGoFetcherDirectQuery(t *testing.T) {
398398 }
399399 gf .env = append (gf .env , "GOPROXY=" + proxyServer .URL )
400400
401- version , time , err := gf .directQuery (context . Background (), tt .path , "latest" )
401+ version , time , err := gf .directQuery (t . Context (), tt .path , "latest" )
402402 if tt .wantErr != nil {
403403 if err == nil {
404404 t .Fatal ("expected error" )
@@ -523,7 +523,7 @@ invalid
523523 gf .initOnce .Do (gf .init )
524524 gf .env = append (gf .env , "GOPROXY=" + proxyServer .URL + "/direct/" )
525525
526- versions , err := gf .List (context . Background (), tt .path )
526+ versions , err := gf .List (t . Context (), tt .path )
527527 if tt .wantErr != nil {
528528 if err == nil {
529529 t .Fatal ("expected error" )
@@ -588,7 +588,7 @@ func TestGoFetcherProxyList(t *testing.T) {
588588 if err != nil {
589589 t .Fatalf ("unexpected error %v" , err )
590590 }
591- versions , err := gf .proxyList (context . Background (), tt .path , proxy )
591+ versions , err := gf .proxyList (t . Context (), tt .path , proxy )
592592 if tt .wantErr != nil {
593593 if err == nil {
594594 t .Fatal ("expected error" )
@@ -652,7 +652,7 @@ func TestGoFetcherDirectList(t *testing.T) {
652652 }
653653 gf .env = append (gf .env , "GOPROXY=" + proxyServer .URL )
654654
655- versions , err := gf .directList (context . Background (), tt .path )
655+ versions , err := gf .directList (t . Context (), tt .path )
656656 if tt .wantErr != nil {
657657 if err == nil {
658658 t .Fatal ("expected error" )
@@ -937,7 +937,7 @@ func TestGoFetcherDownload(t *testing.T) {
937937 gf .initOnce .Do (gf .init )
938938 gf .env = append (gf .env , "GOPROXY=" + proxyServer .URL + "/direct/" )
939939
940- info , mod , zip , err := gf .Download (context . Background (), tt .path , tt .version )
940+ info , mod , zip , err := gf .Download (t . Context (), tt .path , tt .version )
941941 if tt .wantErr != nil {
942942 if err == nil {
943943 t .Fatal ("expected error" )
@@ -1089,7 +1089,7 @@ func TestGoFetcherProxyDownload(t *testing.T) {
10891089 if err != nil {
10901090 t .Fatalf ("unexpected error %v" , err )
10911091 }
1092- infoFile , modFile , zipFile , cleanup , err := gf .proxyDownload (context . Background (), tt .path , tt .version , proxy )
1092+ infoFile , modFile , zipFile , cleanup , err := gf .proxyDownload (t . Context (), tt .path , tt .version , proxy )
10931093 if tt .wantErr != nil {
10941094 if err == nil {
10951095 t .Fatal ("expected error" )
@@ -1193,7 +1193,7 @@ func TestGoFetcherDirectDownload(t *testing.T) {
11931193 }
11941194 gf .env = append (gf .env , "GOPROXY=" + proxyServer .URL )
11951195
1196- infoFile , modFile , zipFile , err := gf .directDownload (context . Background (), tt .path , infoVersion )
1196+ infoFile , modFile , zipFile , err := gf .directDownload (t . Context (), tt .path , infoVersion )
11971197 if tt .wantErr != nil {
11981198 if err == nil {
11991199 t .Fatal ("expected error" )
@@ -1239,7 +1239,7 @@ func (misbehavingDoneContext) Value(key any) any { return nil }
12391239func TestGoFetcherExecGo (t * testing.T ) {
12401240 t .Setenv ("GOMODCACHE" , t .TempDir ())
12411241
1242- ctxCanceled , cancel := context .WithCancel (context . Background ())
1242+ ctxCanceled , cancel := context .WithCancel (t . Context ())
12431243 cancel ()
12441244
12451245 for _ , tt := range []struct {
@@ -1254,19 +1254,19 @@ func TestGoFetcherExecGo(t *testing.T) {
12541254 }{
12551255 {
12561256 n : 1 ,
1257- ctx : context . Background (),
1257+ ctx : t . Context (),
12581258 args : []string {"env" , "GOPROXY" },
12591259 wantOutput : "direct\n " ,
12601260 },
12611261 {
12621262 n : 2 ,
1263- ctx : context . Background (),
1263+ ctx : t . Context (),
12641264 args : []string {"foobar" },
12651265 wantErr : errors .New ("go foobar: unknown command\n Run 'go help' for usage." ),
12661266 },
12671267 {
12681268 n : 3 ,
1269- ctx : context . Background (),
1269+ ctx : t . Context (),
12701270 args : []string {"mod" , "download" , "-json" , "foobar@latest" },
12711271 wantErr : errors .New (`foobar@latest: malformed module path "foobar": missing dot in first path element` ),
12721272 },
@@ -1282,7 +1282,7 @@ func TestGoFetcherExecGo(t *testing.T) {
12821282 },
12831283 {
12841284 n : 6 ,
1285- ctx : context . Background (),
1285+ ctx : t . Context (),
12861286 tempDir : filepath .Join (t .TempDir (), "404" ),
12871287 wantErr : fs .ErrNotExist ,
12881288 },
0 commit comments