+
Skip to content

Add ReRequestCheckRun #2358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions github/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,22 @@ func (s *ChecksService) ListCheckRunsCheckSuite(ctx context.Context, owner, repo
return checkRunResults, resp, nil
}

// ReRequestCheckRun triggers GitHub to rerequest an existing check run.
//
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#rerequest-a-check-run
func (s *ChecksService) ReRequestCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-runs/%v/rerequest", owner, repo, checkRunID)

req, err := s.client.NewRequest("POST", u, nil)
if err != nil {
return nil, err
}

req.Header.Set("Accept", mediaTypeCheckRunsPreview)

return s.client.Do(ctx, req, nil)
}

// ListCheckSuiteOptions represents parameters to list check suites.
type ListCheckSuiteOptions struct {
CheckName *string `url:"check_name,omitempty"` // Filters checks suites by the name of the check run.
Expand Down
25 changes: 25 additions & 0 deletions github/checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1718,3 +1718,28 @@ func TestCheckSuitePreferenceResults_Marshal(t *testing.T) {

testJSONMarshal(t, u, want)
}

func TestChecksService_ReRequestCheckRun(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repos/o/r/check-runs/1/rerequest", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testHeader(t, r, "Accept", mediaTypeCheckRunsPreview)
w.WriteHeader(http.StatusCreated)
})
ctx := context.Background()
resp, err := client.Checks.ReRequestCheckRun(ctx, "o", "r", 1)
if err != nil {
t.Errorf("Checks.ReRequestCheckRun return error: %v", err)
}
if got, want := resp.StatusCode, http.StatusCreated; got != want {
t.Errorf("Checks.ReRequestCheckRun = %v, want %v", got, want)
}

const methodName = "ReRequestCheckRun"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Checks.ReRequestCheckRun(ctx, "\n", "\n", 1)
return err
})
}
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载