Skip to content

Commit

Permalink
feat: Allow for more than 1 recursive redirection upon receiving HTTP…
Browse files Browse the repository at this point in the history
… 301 status
  • Loading branch information
k0ral committed Sep 25, 2023
1 parent aa3fcbe commit 7d6dbef
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 50 deletions.
4 changes: 2 additions & 2 deletions github/actions_artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, ar
// DownloadArtifact gets a redirect URL to download an archive for a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#download-an-artifact
func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, followRedirects bool) (*url.URL, *Response, error) {
func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, maxRedirects int) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v/zip", owner, repo, artifactID)

resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil {
return nil, nil, err
}
Expand Down
14 changes: 7 additions & 7 deletions github/actions_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func TestActionsSerivice_DownloadArtifact(t *testing.T) {
})

ctx := context.Background()
url, resp, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, true)
url, resp, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 1)
if err != nil {
t.Errorf("Actions.DownloadArtifact returned error: %v", err)
}
Expand All @@ -292,7 +292,7 @@ func TestActionsSerivice_DownloadArtifact(t *testing.T) {

const methodName = "DownloadArtifact"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.DownloadArtifact(ctx, "\n", "\n", -1, true)
_, _, err = client.Actions.DownloadArtifact(ctx, "\n", "\n", -1, 1)
return err
})

Expand All @@ -301,7 +301,7 @@ func TestActionsSerivice_DownloadArtifact(t *testing.T) {
return nil, errors.New("failed to download artifact")
})
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.DownloadArtifact(ctx, "o", "r", 1, true)
_, _, err = client.Actions.DownloadArtifact(ctx, "o", "r", 1, 1)
return err
})
}
Expand All @@ -311,7 +311,7 @@ func TestActionsService_DownloadArtifact_invalidOwner(t *testing.T) {
defer teardown()

ctx := context.Background()
_, _, err := client.Actions.DownloadArtifact(ctx, "%", "r", 1, true)
_, _, err := client.Actions.DownloadArtifact(ctx, "%", "r", 1, 1)
testURLParseError(t, err)
}

Expand All @@ -320,7 +320,7 @@ func TestActionsService_DownloadArtifact_invalidRepo(t *testing.T) {
defer teardown()

ctx := context.Background()
_, _, err := client.Actions.DownloadArtifact(ctx, "o", "%", 1, true)
_, _, err := client.Actions.DownloadArtifact(ctx, "o", "%", 1, 1)
testURLParseError(t, err)
}

Expand All @@ -334,7 +334,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_dontFollowRedire
})

ctx := context.Background()
_, resp, _ := client.Actions.DownloadArtifact(ctx, "o", "r", 1, false)
_, resp, _ := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 0)
if resp.StatusCode != http.StatusMovedPermanently {
t.Errorf("Actions.DownloadArtifact return status %d, want %d", resp.StatusCode, http.StatusMovedPermanently)
}
Expand All @@ -355,7 +355,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects(
})

ctx := context.Background()
url, resp, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, true)
url, resp, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 1)
if err != nil {
t.Errorf("Actions.DownloadArtifact return error: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions github/actions_workflow_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo str
// GetWorkflowJobLogs gets a redirect URL to download a plain text file of logs for a workflow job.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#download-job-logs-for-a-workflow-run
func (s *ActionsService) GetWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64, followRedirects bool) (*url.URL, *Response, error) {
func (s *ActionsService) GetWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64, maxRedirects int) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/logs", owner, repo, jobID)

resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil {
return nil, nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions github/actions_workflow_jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestActionsService_GetWorkflowJobLogs(t *testing.T) {
})

ctx := context.Background()
url, resp, err := client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, true)
url, resp, err := client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, 1)
if err != nil {
t.Errorf("Actions.GetWorkflowJobLogs returned error: %v", err)
}
Expand All @@ -152,7 +152,7 @@ func TestActionsService_GetWorkflowJobLogs(t *testing.T) {

const methodName = "GetWorkflowJobLogs"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.GetWorkflowJobLogs(ctx, "\n", "\n", 399444496, true)
_, _, err = client.Actions.GetWorkflowJobLogs(ctx, "\n", "\n", 399444496, 1)
return err
})

Expand All @@ -161,7 +161,7 @@ func TestActionsService_GetWorkflowJobLogs(t *testing.T) {
return nil, errors.New("failed to get workflow logs")
})
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, true)
_, _, err = client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, 1)
return err
})
}
Expand All @@ -176,7 +176,7 @@ func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_dontFollowRedi
})

ctx := context.Background()
_, resp, _ := client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, false)
_, resp, _ := client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, 0)
if resp.StatusCode != http.StatusMovedPermanently {
t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently)
}
Expand All @@ -199,7 +199,7 @@ func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_followRedirect
})

ctx := context.Background()
url, resp, err := client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, true)
url, resp, err := client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, 1)
if err != nil {
t.Errorf("Actions.GetWorkflowJobLogs returned error: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions github/actions_workflow_runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ func (s *ActionsService) GetWorkflowRunAttempt(ctx context.Context, owner, repo
// GetWorkflowRunAttemptLogs gets a redirect URL to download a plain text file of logs for a workflow run for attempt number.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#download-workflow-run-attempt-logs
func (s *ActionsService) GetWorkflowRunAttemptLogs(ctx context.Context, owner, repo string, runID int64, attemptNumber int, followRedirects bool) (*url.URL, *Response, error) {
func (s *ActionsService) GetWorkflowRunAttemptLogs(ctx context.Context, owner, repo string, runID int64, attemptNumber int, maxRedirects int) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/attempts/%v/logs", owner, repo, runID, attemptNumber)

resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -287,10 +287,10 @@ func (s *ActionsService) CancelWorkflowRunByID(ctx context.Context, owner, repo
// GetWorkflowRunLogs gets a redirect URL to download a plain text file of logs for a workflow run.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#download-workflow-run-logs
func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64, followRedirects bool) (*url.URL, *Response, error) {
func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64, maxRedirects int) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID)

resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil {
return nil, nil, err
}
Expand Down
20 changes: 10 additions & 10 deletions github/actions_workflow_runs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func TestActionsService_GetWorkflowRunAttemptLogs(t *testing.T) {
})

ctx := context.Background()
url, resp, err := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, true)
url, resp, err := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, 1)
if err != nil {
t.Errorf("Actions.GetWorkflowRunAttemptLogs returned error: %v", err)
}
Expand All @@ -212,7 +212,7 @@ func TestActionsService_GetWorkflowRunAttemptLogs(t *testing.T) {

const methodName = "GetWorkflowRunAttemptLogs"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.GetWorkflowRunAttemptLogs(ctx, "\n", "\n", 399444496, 2, true)
_, _, err = client.Actions.GetWorkflowRunAttemptLogs(ctx, "\n", "\n", 399444496, 2, 1)
return err
})
}
Expand All @@ -227,7 +227,7 @@ func TestActionsService_GetWorkflowRunAttemptLogs_StatusMovedPermanently_dontFol
})

ctx := context.Background()
_, resp, _ := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, false)
_, resp, _ := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, 0)
if resp.StatusCode != http.StatusMovedPermanently {
t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently)
}
Expand All @@ -250,7 +250,7 @@ func TestActionsService_GetWorkflowRunAttemptLogs_StatusMovedPermanently_followR
})

ctx := context.Background()
url, resp, err := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, true)
url, resp, err := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, 1)
if err != nil {
t.Errorf("Actions.GetWorkflowRunAttemptLogs returned error: %v", err)
}
Expand All @@ -266,7 +266,7 @@ func TestActionsService_GetWorkflowRunAttemptLogs_StatusMovedPermanently_followR

const methodName = "GetWorkflowRunAttemptLogs"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.GetWorkflowRunAttemptLogs(ctx, "\n", "\n", 399444496, 2, true)
_, _, err = client.Actions.GetWorkflowRunAttemptLogs(ctx, "\n", "\n", 399444496, 2, 1)
return err
})
}
Expand Down Expand Up @@ -397,7 +397,7 @@ func TestActionsService_GetWorkflowRunLogs(t *testing.T) {
})

ctx := context.Background()
url, resp, err := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, true)
url, resp, err := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, 1)
if err != nil {
t.Errorf("Actions.GetWorkflowRunLogs returned error: %v", err)
}
Expand All @@ -411,7 +411,7 @@ func TestActionsService_GetWorkflowRunLogs(t *testing.T) {

const methodName = "GetWorkflowRunLogs"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.GetWorkflowRunLogs(ctx, "\n", "\n", 399444496, true)
_, _, err = client.Actions.GetWorkflowRunLogs(ctx, "\n", "\n", 399444496, 1)
return err
})
}
Expand All @@ -426,7 +426,7 @@ func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_dontFollowRedi
})

ctx := context.Background()
_, resp, _ := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, false)
_, resp, _ := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, 0)
if resp.StatusCode != http.StatusMovedPermanently {
t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently)
}
Expand All @@ -449,7 +449,7 @@ func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_followRedirect
})

ctx := context.Background()
url, resp, err := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, true)
url, resp, err := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, 1)
if err != nil {
t.Errorf("Actions.GetWorkflowJobLogs returned error: %v", err)
}
Expand All @@ -465,7 +465,7 @@ func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_followRedirect

const methodName = "GetWorkflowRunLogs"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.GetWorkflowRunLogs(ctx, "\n", "\n", 399444496, true)
_, _, err = client.Actions.GetWorkflowRunLogs(ctx, "\n", "\n", 399444496, 1)
return err
})
}
Expand Down
6 changes: 3 additions & 3 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ func formatRateReset(d time.Duration) string {

// When using roundTripWithOptionalFollowRedirect, note that it
// is the responsibility of the caller to close the response body.
func (c *Client) roundTripWithOptionalFollowRedirect(ctx context.Context, u string, followRedirects bool, opts ...RequestOption) (*http.Response, error) {
func (c *Client) roundTripWithOptionalFollowRedirect(ctx context.Context, u string, maxRedirects int, opts ...RequestOption) (*http.Response, error) {
req, err := c.NewRequest("GET", u, nil, opts...)
if err != nil {
return nil, err
Expand All @@ -1577,10 +1577,10 @@ func (c *Client) roundTripWithOptionalFollowRedirect(ctx context.Context, u stri
}

// If redirect response is returned, follow it
if followRedirects && resp.StatusCode == http.StatusMovedPermanently {
if maxRedirects > 0 && resp.StatusCode == http.StatusMovedPermanently {
_ = resp.Body.Close()
u = resp.Header.Get("Location")
resp, err = c.roundTripWithOptionalFollowRedirect(ctx, u, false, opts...)
resp, err = c.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects-1, opts...)
}
return resp, err
}
Expand Down
4 changes: 2 additions & 2 deletions github/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,10 +1274,10 @@ func (s *RepositoriesService) ListBranches(ctx context.Context, owner string, re
// GetBranch gets the specified branch for a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/branches/branches#get-a-branch
func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch string, followRedirects bool) (*Branch, *Response, error) {
func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch string, maxRedirects int) (*Branch, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/branches/%v", owner, repo, branch)

resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil {
return nil, nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions github/repos_contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,12 @@ const (
// or github.Zipball constant.
//
// GitHub API docs: https://docs.github.com/en/rest/repos/contents/#get-archive-link
func (s *RepositoriesService) GetArchiveLink(ctx context.Context, owner, repo string, archiveformat ArchiveFormat, opts *RepositoryContentGetOptions, followRedirects bool) (*url.URL, *Response, error) {
func (s *RepositoriesService) GetArchiveLink(ctx context.Context, owner, repo string, archiveformat ArchiveFormat, opts *RepositoryContentGetOptions, maxRedirects int) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/%s", owner, repo, archiveformat)
if opts != nil && opts.Ref != "" {
u += fmt.Sprintf("/%s", opts.Ref)
}
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil {
return nil, nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions github/repos_contents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ func TestRepositoriesService_GetArchiveLink(t *testing.T) {
http.Redirect(w, r, "http://github.com/a", http.StatusFound)
})
ctx := context.Background()
url, resp, err := client.Repositories.GetArchiveLink(ctx, "o", "r", Tarball, &RepositoryContentGetOptions{Ref: "yo"}, true)
url, resp, err := client.Repositories.GetArchiveLink(ctx, "o", "r", Tarball, &RepositoryContentGetOptions{Ref: "yo"}, 1)
if err != nil {
t.Errorf("Repositories.GetArchiveLink returned error: %v", err)
}
Expand All @@ -708,7 +708,7 @@ func TestRepositoriesService_GetArchiveLink(t *testing.T) {

const methodName = "GetArchiveLink"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Repositories.GetArchiveLink(ctx, "\n", "\n", Tarball, &RepositoryContentGetOptions{}, true)
_, _, err = client.Repositories.GetArchiveLink(ctx, "\n", "\n", Tarball, &RepositoryContentGetOptions{}, 1)
return err
})

Expand All @@ -717,7 +717,7 @@ func TestRepositoriesService_GetArchiveLink(t *testing.T) {
return nil, errors.New("failed to get archive link")
})
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Repositories.GetArchiveLink(ctx, "o", "r", Tarball, &RepositoryContentGetOptions{}, true)
_, _, err = client.Repositories.GetArchiveLink(ctx, "o", "r", Tarball, &RepositoryContentGetOptions{}, 1)
return err
})
}
Expand All @@ -730,7 +730,7 @@ func TestRepositoriesService_GetArchiveLink_StatusMovedPermanently_dontFollowRed
http.Redirect(w, r, "http://github.com/a", http.StatusMovedPermanently)
})
ctx := context.Background()
_, resp, _ := client.Repositories.GetArchiveLink(ctx, "o", "r", Tarball, &RepositoryContentGetOptions{}, false)
_, resp, _ := client.Repositories.GetArchiveLink(ctx, "o", "r", Tarball, &RepositoryContentGetOptions{}, 0)
if resp.StatusCode != http.StatusMovedPermanently {
t.Errorf("Repositories.GetArchiveLink returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently)
}
Expand All @@ -750,7 +750,7 @@ func TestRepositoriesService_GetArchiveLink_StatusMovedPermanently_followRedirec
http.Redirect(w, r, "http://github.com/a", http.StatusFound)
})
ctx := context.Background()
url, resp, err := client.Repositories.GetArchiveLink(ctx, "o", "r", Tarball, &RepositoryContentGetOptions{}, true)
url, resp, err := client.Repositories.GetArchiveLink(ctx, "o", "r", Tarball, &RepositoryContentGetOptions{}, 1)
if err != nil {
t.Errorf("Repositories.GetArchiveLink returned error: %v", err)
}
Expand Down
12 changes: 6 additions & 6 deletions github/repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ func TestRepositoriesService_GetBranch(t *testing.T) {
})

ctx := context.Background()
branch, _, err := client.Repositories.GetBranch(ctx, "o", "r", "b", false)
branch, _, err := client.Repositories.GetBranch(ctx, "o", "r", "b", 0)
if err != nil {
t.Errorf("Repositories.GetBranch returned error: %v", err)
}
Expand All @@ -947,7 +947,7 @@ func TestRepositoriesService_GetBranch(t *testing.T) {

const methodName = "GetBranch"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", false)
_, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", 0)
return err
})
}
Expand All @@ -962,7 +962,7 @@ func TestRepositoriesService_GetBranch_BadJSONResponse(t *testing.T) {
})

ctx := context.Background()
if _, _, err := client.Repositories.GetBranch(ctx, "o", "r", "b", false); err == nil {
if _, _, err := client.Repositories.GetBranch(ctx, "o", "r", "b", 0); err == nil {
t.Error("Repositories.GetBranch returned no error; wanted JSON error")
}
}
Expand All @@ -981,7 +981,7 @@ func TestRepositoriesService_GetBranch_StatusMovedPermanently_followRedirects(t
fmt.Fprint(w, `{"name":"n", "commit":{"sha":"s","commit":{"message":"m"}}, "protected":true}`)
})
ctx := context.Background()
branch, resp, err := client.Repositories.GetBranch(ctx, "o", "r", "b", true)
branch, resp, err := client.Repositories.GetBranch(ctx, "o", "r", "b", 1)
if err != nil {
t.Errorf("Repositories.GetBranch returned error: %v", err)
}
Expand Down Expand Up @@ -1013,7 +1013,7 @@ func TestRepositoriesService_GetBranch_notFound(t *testing.T) {
http.Error(w, "branch not found", http.StatusNotFound)
})
ctx := context.Background()
_, resp, err := client.Repositories.GetBranch(ctx, "o", "r", "b", true)
_, resp, err := client.Repositories.GetBranch(ctx, "o", "r", "b", 1)
if err == nil {
t.Error("Repositories.GetBranch returned error: nil")
}
Expand All @@ -1028,7 +1028,7 @@ func TestRepositoriesService_GetBranch_notFound(t *testing.T) {

const methodName = "GetBranch"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", true)
_, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", 1)
return err
})
}
Expand Down
Loading

0 comments on commit 7d6dbef

Please sign in to comment.