diff --git a/github/checks.go b/github/checks.go index a861894453..71e50c15f2 100644 --- a/github/checks.go +++ b/github/checks.go @@ -85,7 +85,10 @@ type CheckSuite struct { PullRequests []*PullRequest `json:"pull_requests,omitempty"` // The following fields are only populated by Webhook events. - HeadCommit *Commit `json:"head_commit,omitempty"` + HeadCommit *Commit `json:"head_commit,omitempty"` + LatestCheckRunsCount *int64 `json:"latest_check_runs_count,omitempty"` + Rerequstable *bool `json:"rerequestable,omitempty"` + RunsRerequstable *bool `json:"runs_rerequestable,omitempty"` } func (c CheckRun) String() string { diff --git a/github/checks_test.go b/github/checks_test.go index 2fdd2476e5..48f6370fe9 100644 --- a/github/checks_test.go +++ b/github/checks_test.go @@ -888,6 +888,9 @@ func Test_CheckSuiteMarshal(t *testing.T) { HeadCommit: &Commit{ SHA: String("s"), }, + LatestCheckRunsCount: Int64(1), + Rerequstable: Bool(true), + RunsRerequstable: Bool(true), } w := fmt.Sprintf(`{ @@ -949,7 +952,10 @@ func Test_CheckSuiteMarshal(t *testing.T) { ], "head_commit": { "sha": "s" - } + }, + "latest_check_runs_count": 1, + "rerequestable": true, + "runs_rerequestable": true }`, ts, ts) testJSONMarshal(t, &c, w) diff --git a/github/github-accessors.go b/github/github-accessors.go index 1abbabd0b6..a99a06aa31 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -2286,6 +2286,14 @@ func (c *CheckSuite) GetID() int64 { return *c.ID } +// GetLatestCheckRunsCount returns the LatestCheckRunsCount field if it's non-nil, zero value otherwise. +func (c *CheckSuite) GetLatestCheckRunsCount() int64 { + if c == nil || c.LatestCheckRunsCount == nil { + return 0 + } + return *c.LatestCheckRunsCount +} + // GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. func (c *CheckSuite) GetNodeID() string { if c == nil || c.NodeID == nil { @@ -2302,6 +2310,22 @@ func (c *CheckSuite) GetRepository() *Repository { return c.Repository } +// GetRerequstable returns the Rerequstable field if it's non-nil, zero value otherwise. +func (c *CheckSuite) GetRerequstable() bool { + if c == nil || c.Rerequstable == nil { + return false + } + return *c.Rerequstable +} + +// GetRunsRerequstable returns the RunsRerequstable field if it's non-nil, zero value otherwise. +func (c *CheckSuite) GetRunsRerequstable() bool { + if c == nil || c.RunsRerequstable == nil { + return false + } + return *c.RunsRerequstable +} + // GetStatus returns the Status field if it's non-nil, zero value otherwise. func (c *CheckSuite) GetStatus() string { if c == nil || c.Status == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 6d1419c79f..2db51bab3d 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -2708,6 +2708,16 @@ func TestCheckSuite_GetID(tt *testing.T) { c.GetID() } +func TestCheckSuite_GetLatestCheckRunsCount(tt *testing.T) { + var zeroValue int64 + c := &CheckSuite{LatestCheckRunsCount: &zeroValue} + c.GetLatestCheckRunsCount() + c = &CheckSuite{} + c.GetLatestCheckRunsCount() + c = nil + c.GetLatestCheckRunsCount() +} + func TestCheckSuite_GetNodeID(tt *testing.T) { var zeroValue string c := &CheckSuite{NodeID: &zeroValue} @@ -2725,6 +2735,26 @@ func TestCheckSuite_GetRepository(tt *testing.T) { c.GetRepository() } +func TestCheckSuite_GetRerequstable(tt *testing.T) { + var zeroValue bool + c := &CheckSuite{Rerequstable: &zeroValue} + c.GetRerequstable() + c = &CheckSuite{} + c.GetRerequstable() + c = nil + c.GetRerequstable() +} + +func TestCheckSuite_GetRunsRerequstable(tt *testing.T) { + var zeroValue bool + c := &CheckSuite{RunsRerequstable: &zeroValue} + c.GetRunsRerequstable() + c = &CheckSuite{} + c.GetRunsRerequstable() + c = nil + c.GetRunsRerequstable() +} + func TestCheckSuite_GetStatus(tt *testing.T) { var zeroValue string c := &CheckSuite{Status: &zeroValue} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 8633d837d1..4a210326f9 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -182,22 +182,25 @@ func TestCheckRun_String(t *testing.T) { func TestCheckSuite_String(t *testing.T) { v := CheckSuite{ - ID: Int64(0), - NodeID: String(""), - HeadBranch: String(""), - HeadSHA: String(""), - URL: String(""), - BeforeSHA: String(""), - AfterSHA: String(""), - Status: String(""), - Conclusion: String(""), - CreatedAt: &Timestamp{}, - UpdatedAt: &Timestamp{}, - App: &App{}, - Repository: &Repository{}, - HeadCommit: &Commit{}, - } - want := `github.CheckSuite{ID:0, NodeID:"", HeadBranch:"", HeadSHA:"", URL:"", BeforeSHA:"", AfterSHA:"", Status:"", Conclusion:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, App:github.App{}, Repository:github.Repository{}, HeadCommit:github.Commit{}}` + ID: Int64(0), + NodeID: String(""), + HeadBranch: String(""), + HeadSHA: String(""), + URL: String(""), + BeforeSHA: String(""), + AfterSHA: String(""), + Status: String(""), + Conclusion: String(""), + CreatedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + App: &App{}, + Repository: &Repository{}, + HeadCommit: &Commit{}, + LatestCheckRunsCount: Int64(0), + Rerequstable: Bool(false), + RunsRerequstable: Bool(false), + } + want := `github.CheckSuite{ID:0, NodeID:"", HeadBranch:"", HeadSHA:"", URL:"", BeforeSHA:"", AfterSHA:"", Status:"", Conclusion:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, App:github.App{}, Repository:github.Repository{}, HeadCommit:github.Commit{}, LatestCheckRunsCount:0, Rerequstable:false, RunsRerequstable:false}` if got := v.String(); got != want { t.Errorf("CheckSuite.String = %v, want %v", got, want) }