Repository: google/go-github
Pull request #1156 (2019-04-17 00:32:49)

Fix set check suite preferences options
Fixes https://github.com/google/go-github/issues/1155

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1156?src=pr&el=h1) Report
> Merging [#1156](https://codecov.io/gh/google/go-github/pull/1156?src=pr&el=desc) into [master](https://codecov.io/gh/google/go-github/commit/a8383c7edb4ac91a58ae2b931c0cc32d69c157fc?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1156/graphs/tree.svg?width=650&token=EgYjGjZlI0&height=150&src=pr)](https://codecov.io/gh/google/go-github/pull/1156?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1156   +/-   ##
=======================================
  Coverage   70.17%   70.17%           
=======================================
  Files          84       84           
  Lines        5824     5824           
=======================================
  Hits         4087     4087           
  Misses        952      952           
  Partials      785      785
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1156?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [github/checks.go](https://codecov.io/gh/google/go-github/pull/1156/diff?src=pr&el=tree#diff-Z2l0aHViL2NoZWNrcy5nbw==) | `59.7% <ø> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1156?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1156?src=pr&el=footer). Last update [a8383c7...7e7664d](https://codecov.io/gh/google/go-github/pull/1156?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

ardakuyumcu: Thank you for the swift reviews! 

Patch:
diff --git a/github/apps_marketplace.go b/github/apps_marketplace.go
index 6dd568a2..863ba934 100644
--- a/github/apps_marketplace.go
+++ b/github/apps_marketplace.go
@@ -68,6 +68,7 @@ type MarketplacePlanAccount struct {
 	URL                      *string                   `json:"url,omitempty"`
 	Type                     *string                   `json:"type,omitempty"`
 	ID                       *int64                    `json:"id,omitempty"`
+	NodeID                   *string                   `json:"node_id,omitempty"`
 	Login                    *string                   `json:"login,omitempty"`
 	Email                    *string                   `json:"email,omitempty"`
 	OrganizationBillingEmail *string                   `json:"organization_billing_email,omitempty"`
diff --git a/github/checks.go b/github/checks.go
index 67222d82..34291508 100644
--- a/github/checks.go
+++ b/github/checks.go
@@ -355,7 +355,7 @@ type AutoTriggerCheck struct {
 
 // CheckSuitePreferenceOptions set options for check suite preferences for a repository.
 type CheckSuitePreferenceOptions struct {
-	PreferenceList *PreferenceList `json:"auto_trigger_checks,omitempty"` // A list of auto trigger checks that can be set for a check suite in a repository.
+	AutoTriggerChecks []*AutoTriggerCheck `json:"auto_trigger_checks,omitempty"` // A slice of auto trigger checks that can be set for a check suite in a repository.
 }
 
 // CheckSuitePreferenceResults represents the results of the preference set operation.
@@ -364,7 +364,7 @@ type CheckSuitePreferenceResults struct {
 	Repository  *Repository     `json:"repository,omitempty"`
 }
 
-// PreferenceList represents a list of auto trigger checks for  repository
+// PreferenceList represents a list of auto trigger checks for repository
 type PreferenceList struct {
 	AutoTriggerChecks []*AutoTriggerCheck `json:"auto_trigger_checks,omitempty"` // A slice of auto trigger checks that can be set for a check suite in a repository.
 }
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 65624b9c..5034beb1 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -932,14 +932,6 @@ func (c *CheckSuiteEvent) GetSender() *User {
 	return c.Sender
 }
 
-// GetPreferenceList returns the PreferenceList field.
-func (c *CheckSuitePreferenceOptions) GetPreferenceList() *PreferenceList {
-	if c == nil {
-		return nil
-	}
-	return c.PreferenceList
-}
-
 // GetPreferences returns the Preferences field.
 func (c *CheckSuitePreferenceResults) GetPreferences() *PreferenceList {
 	if c == nil {
@@ -4972,6 +4964,14 @@ func (m *MarketplacePlanAccount) GetMarketplacePurchase() *MarketplacePurchase {
 	return m.MarketplacePurchase
 }
 
+// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise.
+func (m *MarketplacePlanAccount) GetNodeID() string {
+	if m == nil || m.NodeID == nil {
+		return ""
+	}
+	return *m.NodeID
+}
+
 // GetOrganizationBillingEmail returns the OrganizationBillingEmail field if it's non-nil, zero value otherwise.
 func (m *MarketplacePlanAccount) GetOrganizationBillingEmail() string {
 	if m == nil || m.OrganizationBillingEmail == nil {


Test patch:
diff --git a/github/checks_test.go b/github/checks_test.go
index 3170f70d..9e5bc1fc 100644
--- a/github/checks_test.go
+++ b/github/checks_test.go
@@ -396,20 +396,22 @@ func TestChecksService_SetCheckSuitePreferences(t *testing.T) {
 	mux.HandleFunc("/repos/o/r/check-suites/preferences", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, "PATCH")
 		testHeader(t, r, "Accept", mediaTypeCheckRunsPreview)
+		testBody(t, r, `{"auto_trigger_checks":[{"app_id":2,"setting":false}]}`+"\n")
 		fmt.Fprint(w, `{"preferences":{"auto_trigger_checks":[{"app_id": 2,"setting": false}]}}`)
 	})
-	p := &PreferenceList{
-		AutoTriggerChecks: []*AutoTriggerCheck{{
-			AppID:   Int64(2),
-			Setting: Bool(false),
-		}},
-	}
-	opt := CheckSuitePreferenceOptions{PreferenceList: p}
+	a := []*AutoTriggerCheck{{
+		AppID:   Int64(2),
+		Setting: Bool(false),
+	}}
+	opt := CheckSuitePreferenceOptions{AutoTriggerChecks: a}
 	prefResults, _, err := client.Checks.SetCheckSuitePreferences(context.Background(), "o", "r", opt)
 	if err != nil {
 		t.Errorf("Checks.SetCheckSuitePreferences return error: %v", err)
 	}
 
+	p := &PreferenceList{
+		AutoTriggerChecks: a,
+	}
 	want := &CheckSuitePreferenceResults{
 		Preferences: p,
 	}