Skip to content

Commit c1da150

Browse files
committed
Slight changes for unittests
1 parent 7a2e88e commit c1da150

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

github/repos_contents_test.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,18 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) {
303303
})
304304

305305
ctx := context.Background()
306-
_, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil)
306+
reader, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil)
307307
if err == nil {
308308
t.Errorf("Repositories.DownloadContents did not return expected error")
309309
}
310310

311311
if resp == nil {
312312
t.Errorf("Repositories.DownloadContents did not return expected response")
313313
}
314+
315+
if reader != nil {
316+
t.Errorf("Repositories.DownloadContents did not return expected reader")
317+
}
314318
}
315319

316320
func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) {
@@ -332,14 +336,18 @@ func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) {
332336
})
333337

334338
ctx := context.Background()
335-
_, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil)
339+
reader, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil)
336340
if err == nil {
337341
t.Errorf("Repositories.DownloadContents did not return expected error")
338342
}
339343

340344
if resp == nil {
341345
t.Errorf("Repositories.DownloadContents did not return expected response")
342346
}
347+
348+
if reader != nil {
349+
t.Errorf("Repositories.DownloadContents did not return expected reader")
350+
}
343351
}
344352

345353
func TestRepositoriesService_DownloadContentsWithMeta_SuccessForFile(t *testing.T) {
@@ -516,24 +524,32 @@ func TestRepositoriesService_DownloadContentsWithMeta_NoDownloadURL(t *testing.T
516524
"name": "f",
517525
}`)
518526
})
519-
520527
mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) {
521528
testMethod(t, r, "GET")
522529
fmt.Fprint(w, `[{
523530
"type": "file",
524531
"name": "f",
532+
"content": ""
525533
}]`)
526534
})
527535

528536
ctx := context.Background()
529-
_, _, resp, err := client.Repositories.DownloadContentsWithMeta(ctx, "o", "r", "d/f", nil)
537+
reader, contents, resp, err := client.Repositories.DownloadContentsWithMeta(ctx, "o", "r", "d/f", nil)
530538
if err == nil {
531539
t.Errorf("Repositories.DownloadContentsWithMeta did not return expected error")
532540
}
533541

542+
if reader != nil {
543+
t.Errorf("Repositories.DownloadContentsWithMeta did not return expected reader")
544+
}
545+
534546
if resp == nil {
535547
t.Errorf("Repositories.DownloadContentsWithMeta did not return expected response")
536548
}
549+
550+
if contents == nil {
551+
t.Errorf("Repositories.DownloadContentsWithMeta did not return expected content")
552+
}
537553
}
538554

539555
func TestRepositoriesService_DownloadContentsWithMeta_NoFile(t *testing.T) {

0 commit comments

Comments
 (0)