From 989b582b92512c43faeab9e8ba10cc1ae412be03 Mon Sep 17 00:00:00 2001 From: Timofei Kuzmin Date: Fri, 2 May 2025 15:28:56 +0400 Subject: [PATCH 1/7] Refactored DownloadContentsWithMeta --- github/repos_contents.go | 33 ++++++++++++++++++--------------- github/repos_contents_test.go | 15 ++++++++------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/github/repos_contents.go b/github/repos_contents.go index 013993e5be1..7baddce6375 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -181,28 +181,31 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owner, repo, filepath string, opts *RepositoryContentGetOptions) (io.ReadCloser, *RepositoryContent, *Response, error) { dir := path.Dir(filepath) filename := path.Base(filepath) - _, dirContents, resp, err := s.GetContents(ctx, owner, repo, dir, opts) + fileContent, _, resp, err := s.GetContents(ctx, owner, repo, filepath, opts) if err != nil { return nil, nil, resp, err } - for _, contents := range dirContents { - if *contents.Name == filename { - if contents.DownloadURL == nil || *contents.DownloadURL == "" { - return nil, contents, resp, fmt.Errorf("no download link found for %s", filepath) - } + if fileContent != nil { + content, err := fileContent.GetContent() + if err == nil && content != "" { + return io.NopCloser(strings.NewReader(content)), fileContent, resp, nil + } - dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *contents.DownloadURL, nil) - if err != nil { - return nil, contents, resp, err - } - dlResp, err := s.client.client.Do(dlReq) - if err != nil { - return nil, contents, &Response{Response: dlResp}, err - } + if fileContent.DownloadURL == nil || *fileContent.DownloadURL == "" { + return nil, fileContent, resp, fmt.Errorf("no download link found for %s", filepath) + } - return dlResp.Body, contents, &Response{Response: dlResp}, nil + dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *fileContent.DownloadURL, nil) + if err != nil { + return nil, fileContent, resp, err + } + dlResp, err := s.client.client.Do(dlReq) + if err != nil { + return nil, fileContent, &Response{Response: dlResp}, err } + + return dlResp.Body, fileContent, &Response{Response: dlResp}, nil } return nil, nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir) diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index d19bf71f35a..5bc9937e369 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -265,13 +265,14 @@ func TestRepositoriesService_DownloadContentsWithMeta_Success(t *testing.T) { t.Parallel() client, mux, serverURL := setup(t) - mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `[{ + fmt.Fprint(w, `{ "type": "file", "name": "f", - "download_url": "`+serverURL+baseURLPath+`/download/f" - }]`) + "download_url": "`+serverURL+baseURLPath+`/download/f", + "content": "foo" + }`) }) mux.HandleFunc("/download/f", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -328,13 +329,13 @@ func TestRepositoriesService_DownloadContentsWithMeta_FailedResponse(t *testing. t.Parallel() client, mux, serverURL := setup(t) - mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `[{ + fmt.Fprint(w, `{ "type": "file", "name": "f", "download_url": "`+serverURL+baseURLPath+`/download/f" - }]`) + }`) }) mux.HandleFunc("/download/f", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") From 2067d4bb172f309e31f63e684d4d99f9d22f2f98 Mon Sep 17 00:00:00 2001 From: Timofei Kuzmin Date: Fri, 9 May 2025 04:01:40 +0400 Subject: [PATCH 2/7] Refactored DownloadContentsWithMeta method, used bcombined approach, updated tests --- github/repos_contents.go | 33 +++++++++++++++++++++------------ github/repos_contents_test.go | 20 +++++++++++++++++++- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/github/repos_contents.go b/github/repos_contents.go index 7baddce6375..5355c560459 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -191,21 +191,30 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne if err == nil && content != "" { return io.NopCloser(strings.NewReader(content)), fileContent, resp, nil } + } - if fileContent.DownloadURL == nil || *fileContent.DownloadURL == "" { - return nil, fileContent, resp, fmt.Errorf("no download link found for %s", filepath) - } + _, dirContents, resp, err := s.GetContents(ctx, owner, repo, dir, opts) + if err != nil { + return nil, nil, resp, err + } - dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *fileContent.DownloadURL, nil) - if err != nil { - return nil, fileContent, resp, err - } - dlResp, err := s.client.client.Do(dlReq) - if err != nil { - return nil, fileContent, &Response{Response: dlResp}, err - } + for _, contents := range dirContents { + if contents.GetName() == filename { + if contents.GetDownloadURL() == "" { + return nil, contents, resp, fmt.Errorf("no download link found for %s", filepath) + } - return dlResp.Body, fileContent, &Response{Response: dlResp}, nil + dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *contents.DownloadURL, nil) + if err != nil { + return nil, contents, resp, err + } + dlResp, err := s.client.client.Do(dlReq) + if err != nil { + return nil, contents, &Response{Response: dlResp}, err + } + + return dlResp.Body, contents, &Response{Response: dlResp}, nil + } } return nil, nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir) diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 5bc9937e369..137a08cab0a 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -329,12 +329,14 @@ func TestRepositoriesService_DownloadContentsWithMeta_FailedResponse(t *testing. t.Parallel() client, mux, serverURL := setup(t) + downloadURL := fmt.Sprintf("%s%s/download/f", serverURL, baseURLPath) + mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `{ "type": "file", "name": "f", - "download_url": "`+serverURL+baseURLPath+`/download/f" + "download_url": "`+downloadURL+`" }`) }) mux.HandleFunc("/download/f", func(w http.ResponseWriter, r *http.Request) { @@ -342,6 +344,14 @@ func TestRepositoriesService_DownloadContentsWithMeta_FailedResponse(t *testing. w.WriteHeader(http.StatusInternalServerError) fmt.Fprint(w, "foo error") }) + mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `[{ + "type": "file", + "name": "f", + "download_url": "`+downloadURL+`" + }]`) + }) ctx := context.Background() r, c, resp, err := client.Repositories.DownloadContentsWithMeta(ctx, "o", "r", "d/f", nil) @@ -376,6 +386,14 @@ func TestRepositoriesService_DownloadContentsWithMeta_NoDownloadURL(t *testing.T t.Parallel() client, mux, _ := setup(t) + mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "type": "file", + "name": "f", + }`) + }) + mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `[{ From cf44be7a923beb3dc33ee3a72b5b5309e792e75b Mon Sep 17 00:00:00 2001 From: Timofei Kuzmin Date: Sat, 10 May 2025 02:48:14 +0400 Subject: [PATCH 3/7] Refactored DownloadContents method --- github/repos_contents.go | 16 +++++++- github/repos_contents_test.go | 73 ++++++++++++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/github/repos_contents.go b/github/repos_contents.go index 5355c560459..70a25847f1d 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -139,14 +139,26 @@ func (s *RepositoriesService) GetReadme(ctx context.Context, owner, repo string, func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, filepath string, opts *RepositoryContentGetOptions) (io.ReadCloser, *Response, error) { dir := path.Dir(filepath) filename := path.Base(filepath) + fileContent, _, resp, err := s.GetContents(ctx, owner, repo, filepath, opts) + if err != nil { + return nil, resp, err + } + + if fileContent != nil { + content, err := fileContent.GetContent() + if err == nil && content != "" { + return io.NopCloser(strings.NewReader(content)), resp, nil + } + } + _, dirContents, resp, err := s.GetContents(ctx, owner, repo, dir, opts) if err != nil { return nil, resp, err } for _, contents := range dirContents { - if *contents.Name == filename { - if contents.DownloadURL == nil || *contents.DownloadURL == "" { + if contents.GetName() == filename { + if contents.GetDownloadURL() == "" { return nil, resp, fmt.Errorf("no download link found for %s", filepath) } diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 137a08cab0a..60b03318891 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -127,10 +127,66 @@ func TestRepositoriesService_GetReadme(t *testing.T) { }) } -func TestRepositoriesService_DownloadContents_Success(t *testing.T) { +func TestRepositoriesService_DownloadContents_SuccessForFile(t *testing.T) { t.Parallel() client, mux, serverURL := setup(t) + mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "type": "file", + "name": "f", + "content": "foo", + "download_url": "`+serverURL+baseURLPath+`/download/f" + }`) + }) + + ctx := context.Background() + r, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil) + if err != nil { + t.Errorf("Repositories.DownloadContents returned error: %v", err) + } + + if got, want := resp.Response.StatusCode, http.StatusOK; got != want { + t.Errorf("Repositories.DownloadContents returned status code %v, want %v", got, want) + } + + bytes, err := io.ReadAll(r) + if err != nil { + t.Errorf("Error reading response body: %v", err) + } + r.Close() + + if got, want := string(bytes), "foo"; got != want { + t.Errorf("Repositories.DownloadContents returned %v, want %v", got, want) + } + + const methodName = "DownloadContents" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Repositories.DownloadContents(ctx, "\n", "\n", "\n", nil) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + +func TestRepositoriesService_DownloadContents_SuccessForDirectory(t *testing.T) { + t.Parallel() + client, mux, serverURL := setup(t) + + mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "type": "file", + "name": "f" + }`) + }) mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `[{ @@ -183,6 +239,13 @@ func TestRepositoriesService_DownloadContents_FailedResponse(t *testing.T) { t.Parallel() client, mux, serverURL := setup(t) + mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "type": "file", + "name": "f" + }`) + }) mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `[{ @@ -222,6 +285,14 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { t.Parallel() client, mux, _ := setup(t) + mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "type": "file", + "name": "f", + "content": "" + }`) + }) mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `[{ From 32e33f62b5defcc2e2b6e8bbfdf578b460774702 Mon Sep 17 00:00:00 2001 From: Timofei Kuzmin Date: Sun, 11 May 2025 01:51:02 +0400 Subject: [PATCH 4/7] PR #3573. Fix for old approach --- github/repos_contents.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/github/repos_contents.go b/github/repos_contents.go index 70a25847f1d..3ca27b1476b 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -140,11 +140,8 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, dir := path.Dir(filepath) filename := path.Base(filepath) fileContent, _, resp, err := s.GetContents(ctx, owner, repo, filepath, opts) - if err != nil { - return nil, resp, err - } - if fileContent != nil { + if err == nil && fileContent != nil { content, err := fileContent.GetContent() if err == nil && content != "" { return io.NopCloser(strings.NewReader(content)), resp, nil @@ -194,11 +191,8 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne dir := path.Dir(filepath) filename := path.Base(filepath) fileContent, _, resp, err := s.GetContents(ctx, owner, repo, filepath, opts) - if err != nil { - return nil, nil, resp, err - } - if fileContent != nil { + if err == nil && fileContent != nil { content, err := fileContent.GetContent() if err == nil && content != "" { return io.NopCloser(strings.NewReader(content)), fileContent, resp, nil From a8ff9b2e23c326722f6a2b7acb55ebd142c6eadd Mon Sep 17 00:00:00 2001 From: Timofei Kuzmin Date: Sun, 11 May 2025 02:48:50 +0400 Subject: [PATCH 5/7] Removed unnecessary spaces --- github/repos_contents.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/github/repos_contents.go b/github/repos_contents.go index 3ca27b1476b..5d7329c4ffe 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -140,7 +140,6 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, dir := path.Dir(filepath) filename := path.Base(filepath) fileContent, _, resp, err := s.GetContents(ctx, owner, repo, filepath, opts) - if err == nil && fileContent != nil { content, err := fileContent.GetContent() if err == nil && content != "" { @@ -158,7 +157,6 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, if contents.GetDownloadURL() == "" { return nil, resp, fmt.Errorf("no download link found for %s", filepath) } - dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *contents.DownloadURL, nil) if err != nil { return nil, resp, err @@ -191,7 +189,6 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne dir := path.Dir(filepath) filename := path.Base(filepath) fileContent, _, resp, err := s.GetContents(ctx, owner, repo, filepath, opts) - if err == nil && fileContent != nil { content, err := fileContent.GetContent() if err == nil && content != "" { @@ -209,7 +206,6 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne if contents.GetDownloadURL() == "" { return nil, contents, resp, fmt.Errorf("no download link found for %s", filepath) } - dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *contents.DownloadURL, nil) if err != nil { return nil, contents, resp, err From 7a2e88e0295fe5942631cdf74f75e1398292307d Mon Sep 17 00:00:00 2001 From: Timofei Kuzmin Date: Sun, 11 May 2025 04:42:25 +0400 Subject: [PATCH 6/7] PR #3573, added more test cases --- github/repos_contents_test.go | 62 ++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 60b03318891..754beef114f 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -298,6 +298,7 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { fmt.Fprint(w, `[{ "type": "file", "name": "f", + "content": "" }]`) }) @@ -316,6 +317,15 @@ func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { t.Parallel() client, mux, _ := setup(t) + mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "type": "file", + "name": "f", + "content": "" + }`) + }) + mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `[]`) @@ -332,7 +342,7 @@ func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { } } -func TestRepositoriesService_DownloadContentsWithMeta_Success(t *testing.T) { +func TestRepositoriesService_DownloadContentsWithMeta_SuccessForFile(t *testing.T) { t.Parallel() client, mux, serverURL := setup(t) @@ -345,10 +355,6 @@ func TestRepositoriesService_DownloadContentsWithMeta_Success(t *testing.T) { "content": "foo" }`) }) - mux.HandleFunc("/download/f", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - fmt.Fprint(w, "foo") - }) ctx := context.Background() r, c, resp, err := client.Repositories.DownloadContentsWithMeta(ctx, "o", "r", "d/f", nil) @@ -396,6 +402,52 @@ func TestRepositoriesService_DownloadContentsWithMeta_Success(t *testing.T) { }) } +func TestRepositoriesService_DownloadContentsWithMeta_SuccessForDirectory(t *testing.T) { + t.Parallel() + client, mux, serverURL := setup(t) + + mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `[{ + "type": "file", + "name": "f", + "download_url": "`+serverURL+baseURLPath+`/download/f" + }]`) + }) + mux.HandleFunc("/download/f", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, "foo") + }) + + ctx := context.Background() + r, c, resp, err := client.Repositories.DownloadContentsWithMeta(ctx, "o", "r", "d/f", nil) + if err != nil { + t.Errorf("Repositories.DownloadContentsWithMeta returned error: %v", err) + } + + if got, want := resp.Response.StatusCode, http.StatusOK; got != want { + t.Errorf("Repositories.DownloadContentsWithMeta returned status code %v, want %v", got, want) + } + + bytes, err := io.ReadAll(r) + if err != nil { + t.Errorf("Error reading response body: %v", err) + } + r.Close() + + if got, want := string(bytes), "foo"; got != want { + t.Errorf("Repositories.DownloadContentsWithMeta returned %v, want %v", got, want) + } + + if c != nil && c.Name != nil { + if got, want := *c.Name, "f"; got != want { + t.Errorf("Repositories.DownloadContentsWithMeta returned content name %v, want %v", got, want) + } + } else { + t.Errorf("Returned RepositoryContent is null") + } +} + func TestRepositoriesService_DownloadContentsWithMeta_FailedResponse(t *testing.T) { t.Parallel() client, mux, serverURL := setup(t) From c1da15061f0500b4d41708c5f8c8ada7ff20cc94 Mon Sep 17 00:00:00 2001 From: Timofei Kuzmin Date: Sun, 11 May 2025 05:17:52 +0400 Subject: [PATCH 7/7] Slight changes for unittests --- github/repos_contents_test.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 754beef114f..1db41a4c1d2 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -303,7 +303,7 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { }) ctx := context.Background() - _, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil) + reader, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil) if err == nil { t.Errorf("Repositories.DownloadContents did not return expected error") } @@ -311,6 +311,10 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { if resp == nil { t.Errorf("Repositories.DownloadContents did not return expected response") } + + if reader != nil { + t.Errorf("Repositories.DownloadContents did not return expected reader") + } } func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { @@ -332,7 +336,7 @@ func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { }) ctx := context.Background() - _, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil) + reader, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil) if err == nil { t.Errorf("Repositories.DownloadContents did not return expected error") } @@ -340,6 +344,10 @@ func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { if resp == nil { t.Errorf("Repositories.DownloadContents did not return expected response") } + + if reader != nil { + t.Errorf("Repositories.DownloadContents did not return expected reader") + } } func TestRepositoriesService_DownloadContentsWithMeta_SuccessForFile(t *testing.T) { @@ -516,24 +524,32 @@ func TestRepositoriesService_DownloadContentsWithMeta_NoDownloadURL(t *testing.T "name": "f", }`) }) - mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `[{ "type": "file", "name": "f", + "content": "" }]`) }) ctx := context.Background() - _, _, resp, err := client.Repositories.DownloadContentsWithMeta(ctx, "o", "r", "d/f", nil) + reader, contents, resp, err := client.Repositories.DownloadContentsWithMeta(ctx, "o", "r", "d/f", nil) if err == nil { t.Errorf("Repositories.DownloadContentsWithMeta did not return expected error") } + if reader != nil { + t.Errorf("Repositories.DownloadContentsWithMeta did not return expected reader") + } + if resp == nil { t.Errorf("Repositories.DownloadContentsWithMeta did not return expected response") } + + if contents == nil { + t.Errorf("Repositories.DownloadContentsWithMeta did not return expected content") + } } func TestRepositoriesService_DownloadContentsWithMeta_NoFile(t *testing.T) {