Repository: google/go-github
Pull request #3278 (2024-09-21 09:17:26)

Add missing fields to the checksuite event
fixes https://github.com/google/go-github/issues/3277

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3278?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 92.94%. Comparing base [(`2b8c7fa`)](https://app.codecov.io/gh/google/go-github/commit/2b8c7fa86fcd1cb4a89a44c8e7b5a49fe4be8a45?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`2674d50`)](https://app.codecov.io/gh/google/go-github/commit/2674d503203c6a5cd5b089ef71a0d80db5a08c04?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> Report is 114 commits behind head on master.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #3278      +/-   ##
==========================================
- Coverage   97.72%   92.94%   -4.78%     
==========================================
  Files         153      171      +18     
  Lines       13390    11669    -1721     
==========================================
- Hits        13085    10846    -2239     
- Misses        215      729     +514     
- Partials       90       94       +4     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3278?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).


Patch:
diff --git a/github/checks.go b/github/checks.go
index a8618944..71e50c15 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/github-accessors.go b/github/github-accessors.go
index 1abbabd0..a99a06aa 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 {


Test patch:
diff --git a/github/checks_test.go b/github/checks_test.go
index 2fdd2476..48f6370f 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_test.go b/github/github-accessors_test.go
index 6d1419c7..2db51bab 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 8633d837..4a210326 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)
 	}