@@ -171,15 +171,16 @@ func testFSWithErrors(t *testing.T, h *testhelper.Helper, fsOpts testhelper.Brok
171171 require .NoError (t , err )
172172
173173 testRepo := tests [0 ].repoIDs [0 ]
174- err = Download ( context . Background (), & library.Job {
174+ job := & library.Job {
175175 Lib : lib ,
176176 Type : library .JobDownload ,
177- Endpoints : []string {endPoint (gitProtocol , testRepo )},
178177 TempFS : h .TempFS ,
179178 AuthToken : func (string ) string { return "" },
180179 Logger : log .New (nil ),
181- })
180+ }
181+ job .SetEndpoints ([]string {endPoint (gitProtocol , testRepo )})
182182
183+ err = Download (context .Background (), job )
183184 require .Error (t , err )
184185 require .Contains (t , err .Error (), errBrokenFS .Error ())
185186}
@@ -195,14 +196,16 @@ func testAuthSuccess(t *testing.T, h *testhelper.Helper) {
195196 t .Skip ()
196197 }
197198
198- require . NoError ( t , Download ( context . Background (), & library.Job {
199+ job := & library.Job {
199200 Lib : h .Lib ,
200201 Type : library .JobDownload ,
201- Endpoints : []string {endPoint (httpsProtocol , testPrivateRepo .repoIDs [0 ])},
202202 TempFS : h .TempFS ,
203203 AuthToken : func (string ) string { return token },
204204 Logger : log .New (nil ),
205- }))
205+ }
206+ job .SetEndpoints ([]string {endPoint (httpsProtocol , testPrivateRepo .repoIDs [0 ])})
207+
208+ require .NoError (t , Download (context .Background (), job ))
206209}
207210
208211// testAuthErrors
@@ -212,14 +215,16 @@ func testAuthSuccess(t *testing.T, h *testhelper.Helper) {
212215// <expected> error: authentication required
213216func testAuthErrors (t * testing.T , h * testhelper.Helper ) {
214217 getJob := func (p protocol ) * library.Job {
215- return & library.Job {
218+ job := & library.Job {
216219 Lib : h .Lib ,
217220 Type : library .JobDownload ,
218- Endpoints : []string {endPoint (p , testPrivateRepo .repoIDs [0 ])},
219221 TempFS : h .TempFS ,
220222 AuthToken : func (string ) string { return "42" },
221223 Logger : log .New (nil ),
222224 }
225+ job .SetEndpoints ([]string {endPoint (p , testPrivateRepo .repoIDs [0 ])})
226+
227+ return job
223228 }
224229
225230 ctx := context .Background ()
@@ -236,14 +241,16 @@ func testContextCancelledFail(t *testing.T, h *testhelper.Helper) {
236241 cancel ()
237242
238243 testRepo := tests [0 ].repoIDs [0 ]
239- require . Equal ( t , fmt . Errorf ( "context canceled" ), Download ( ctx , & library.Job {
244+ job := & library.Job {
240245 Lib : h .Lib ,
241246 Type : library .JobDownload ,
242- Endpoints : []string {endPoint (gitProtocol , testRepo )},
243247 TempFS : h .TempFS ,
244248 AuthToken : func (string ) string { return "" },
245249 Logger : log .New (nil ),
246- }))
250+ }
251+ job .SetEndpoints ([]string {endPoint (gitProtocol , testRepo )})
252+
253+ require .Equal (t , fmt .Errorf ("context canceled" ), Download (ctx , job ))
247254}
248255
249256// testWrongEndpointFail
@@ -253,14 +260,16 @@ func testContextCancelledFail(t *testing.T, h *testhelper.Helper) {
253260func testWrongEndpointFail (t * testing.T , h * testhelper.Helper ) {
254261 const corruptedEndpoint = "git://42.git"
255262
256- err := Download ( context . Background (), & library.Job {
263+ job := & library.Job {
257264 Lib : h .Lib ,
258265 Type : library .JobDownload ,
259- Endpoints : []string {corruptedEndpoint },
260266 TempFS : h .TempFS ,
261267 AuthToken : func (string ) string { return "" },
262268 Logger : log .New (nil ),
263- })
269+ }
270+ job .SetEndpoints ([]string {corruptedEndpoint })
271+
272+ err := Download (context .Background (), job )
264273 require .Error (t , err )
265274
266275 e , ok := err .(* net.OpError )
@@ -279,11 +288,11 @@ func testAlreadyDownloadedFail(t *testing.T, h *testhelper.Helper) {
279288 job := & library.Job {
280289 Lib : h .Lib ,
281290 Type : library .JobDownload ,
282- Endpoints : []string {endPoint (gitProtocol , testRepo )},
283291 TempFS : h .TempFS ,
284292 AuthToken : func (string ) string { return "" },
285293 Logger : log .New (nil ),
286294 }
295+ job .SetEndpoints ([]string {endPoint (gitProtocol , testRepo )})
287296
288297 ctx := context .Background ()
289298 require .NoError (t , Download (ctx , job ))
@@ -401,11 +410,11 @@ func concurrentDownloads(h *testhelper.Helper, p protocol) chan error {
401410 job := & library.Job {
402411 Lib : h .Lib ,
403412 Type : library .JobDownload ,
404- Endpoints : []string {endPoint (p , id )},
405413 TempFS : h .TempFS ,
406414 AuthToken : func (string ) string { return "" },
407415 Logger : log .New (nil ),
408416 }
417+ job .SetEndpoints ([]string {endPoint (p , id )})
409418
410419 jobs = append (jobs , job )
411420 }
0 commit comments