Repository: google/go-github
Pull request #2017 (2021-07-21 05:28:32)

Fix deprecated field
The deprecated field `open` got changed to `state` to hold 3 different values (`open, dismissed, and fixed`)

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/2017?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2017](https://codecov.io/gh/google/go-github/pull/2017?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (db7f325) into [master](https://codecov.io/gh/google/go-github/commit/b8294c36e447250ab6493d5f73337eb412be6941?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (b8294c3) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/2017/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)](https://codecov.io/gh/google/go-github/pull/2017?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)

```diff
@@           Coverage Diff           @@
##           master    #2017   +/-   ##
=======================================
  Coverage   97.86%   97.86%           
=======================================
  Files         107      107           
  Lines        6897     6897           
=======================================
  Hits         6750     6750           
  Misses         81       81           
  Partials       66       66           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/2017?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/code-scanning.go](https://codecov.io/gh/google/go-github/pull/2017/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2NvZGUtc2Nhbm5pbmcuZ28=) | `100.00% <ø> (ø)` | |

------

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


Patch:
diff --git a/README.md b/README.md
index 6effaf7c..838de4fa 100644
--- a/README.md
+++ b/README.md
@@ -250,6 +250,10 @@ For complete usage of go-github, see the full [package docs][].
 [GraphQL API v4]: https://developer.github.com/v4/
 [shurcooL/githubv4]: https://github.com/shurcooL/githubv4
 
+### Testing code that uses `go-github`
+
+The repo [migueleliasweb/go-github-mock](https://github.com/migueleliasweb/go-github-mock) provides a way to mock responses. Check the repo for more details.
+
 ### Integration Tests ###
 
 You can run integration tests from the `test` directory. See the integration tests [README](test/README.md).
diff --git a/github/apps_manifest.go b/github/apps_manifest.go
index defd6c0a..164f4939 100644
--- a/github/apps_manifest.go
+++ b/github/apps_manifest.go
@@ -13,6 +13,7 @@ import (
 // AppConfig describes the configuration of a GitHub App.
 type AppConfig struct {
 	ID            *int64     `json:"id,omitempty"`
+	Slug          *string    `json:"slug,omitempty"`
 	NodeID        *string    `json:"node_id,omitempty"`
 	Owner         *User      `json:"owner,omitempty"`
 	Name          *string    `json:"name,omitempty"`
diff --git a/github/code-scanning.go b/github/code-scanning.go
index 640ec899..dbaeb346 100644
--- a/github/code-scanning.go
+++ b/github/code-scanning.go
@@ -20,13 +20,14 @@ type CodeScanningService service
 
 // Rule represents the complete details of GitHub Code Scanning alert type.
 type Rule struct {
-	ID              *string  `json:"id,omitempty"`
-	Severity        *string  `json:"severity,omitempty"`
-	Description     *string  `json:"description,omitempty"`
-	Name            *string  `json:"name,omitempty"`
-	FullDescription *string  `json:"full_description,omitempty"`
-	Tags            []string `json:"tags,omitempty"`
-	Help            *string  `json:"help,omitempty"`
+	ID                    *string  `json:"id,omitempty"`
+	Severity              *string  `json:"severity,omitempty"`
+	Description           *string  `json:"description,omitempty"`
+	Name                  *string  `json:"name,omitempty"`
+	SecuritySeverityLevel *string  `json:"security_severity_level,omitempty"`
+	FullDescription       *string  `json:"full_description,omitempty"`
+	Tags                  []string `json:"tags,omitempty"`
+	Help                  *string  `json:"help,omitempty"`
 }
 
 // Location represents the exact location of the GitHub Code Scanning Alert in the scanned project.
@@ -72,7 +73,7 @@ type Alert struct {
 	Rule               *Rule               `json:"rule,omitempty"`
 	Tool               *Tool               `json:"tool,omitempty"`
 	CreatedAt          *Timestamp          `json:"created_at,omitempty"`
-	Open               *bool               `json:"open,omitempty"`
+	State              *string             `json:"state,omitempty"`
 	ClosedBy           *User               `json:"closed_by,omitempty"`
 	ClosedAt           *Timestamp          `json:"closed_at,omitempty"`
 	URL                *string             `json:"url,omitempty"`
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 2d51bfdf..37a22830 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -220,14 +220,6 @@ func (a *Alert) GetMostRecentInstance() *MostRecentInstance {
 	return a.MostRecentInstance
 }
 
-// GetOpen returns the Open field if it's non-nil, zero value otherwise.
-func (a *Alert) GetOpen() bool {
-	if a == nil || a.Open == nil {
-		return false
-	}
-	return *a.Open
-}
-
 // GetRule returns the Rule field.
 func (a *Alert) GetRule() *Rule {
 	if a == nil {
@@ -260,6 +252,14 @@ func (a *Alert) GetRuleSeverity() string {
 	return *a.RuleSeverity
 }
 
+// GetState returns the State field if it's non-nil, zero value otherwise.
+func (a *Alert) GetState() string {
+	if a == nil || a.State == nil {
+		return ""
+	}
+	return *a.State
+}
+
 // GetTool returns the Tool field.
 func (a *Alert) GetTool() *Tool {
 	if a == nil {
@@ -460,6 +460,14 @@ func (a *AppConfig) GetPEM() string {
 	return *a.PEM
 }
 
+// GetSlug returns the Slug field if it's non-nil, zero value otherwise.
+func (a *AppConfig) GetSlug() string {
+	if a == nil || a.Slug == nil {
+		return ""
+	}
+	return *a.Slug
+}
+
 // GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise.
 func (a *AppConfig) GetUpdatedAt() Timestamp {
 	if a == nil || a.UpdatedAt == nil {
@@ -14212,6 +14220,14 @@ func (r *RepoStats) GetTotalWikis() int {
 	return *r.TotalWikis
 }
 
+// GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise.
+func (r *RepoStatus) GetAvatarURL() string {
+	if r == nil || r.AvatarURL == nil {
+		return ""
+	}
+	return *r.AvatarURL
+}
+
 // GetContext returns the Context field if it's non-nil, zero value otherwise.
 func (r *RepoStatus) GetContext() string {
 	if r == nil || r.Context == nil {
@@ -14356,6 +14372,14 @@ func (r *Rule) GetName() string {
 	return *r.Name
 }
 
+// GetSecuritySeverityLevel returns the SecuritySeverityLevel field if it's non-nil, zero value otherwise.
+func (r *Rule) GetSecuritySeverityLevel() string {
+	if r == nil || r.SecuritySeverityLevel == nil {
+		return ""
+	}
+	return *r.SecuritySeverityLevel
+}
+
 // GetSeverity returns the Severity field if it's non-nil, zero value otherwise.
 func (r *Rule) GetSeverity() string {
 	if r == nil || r.Severity == nil {
diff --git a/github/github.go b/github/github.go
index ae0ee08c..2f765365 100644
--- a/github/github.go
+++ b/github/github.go
@@ -188,6 +188,14 @@ type service struct {
 	client *Client
 }
 
+// Client returns the http.Client used by this GitHub client.
+func (c *Client) Client() *http.Client {
+	c.clientMu.Lock()
+	defer c.clientMu.Unlock()
+	clientCopy := *c.client
+	return &clientCopy
+}
+
 // ListOptions specifies the optional parameters to various List methods that
 // support offset pagination.
 type ListOptions struct {
diff --git a/github/repos_statuses.go b/github/repos_statuses.go
index 32929ba3..347d856a 100644
--- a/github/repos_statuses.go
+++ b/github/repos_statuses.go
@@ -31,6 +31,9 @@ type RepoStatus struct {
 	// A string label to differentiate this status from the statuses of other systems.
 	Context *string `json:"context,omitempty"`
 
+	// AvatarURL is the URL of the avatar of this status.
+	AvatarURL *string `json:"avatar_url,omitempty"`
+
 	Creator   *User      `json:"creator,omitempty"`
 	CreatedAt *time.Time `json:"created_at,omitempty"`
 	UpdatedAt *time.Time `json:"updated_at,omitempty"`


Test patch:
diff --git a/github/apps_manifest_test.go b/github/apps_manifest_test.go
index a5d230d0..833982e4 100644
--- a/github/apps_manifest_test.go
+++ b/github/apps_manifest_test.go
@@ -72,6 +72,7 @@ func TestAppConfig_Marshal(t *testing.T) {
 
 	u := &AppConfig{
 		ID:     Int64(1),
+		Slug:   String("s"),
 		NodeID: String("nid"),
 		Owner: &User{
 			Login:           String("l"),
@@ -107,6 +108,7 @@ func TestAppConfig_Marshal(t *testing.T) {
 
 	want := `{
 		"id": 1,
+		"slug": "s",
 		"node_id": "nid",
 		"owner": {
 			"login": "l",
diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go
index 7403582f..6ef8d84a 100644
--- a/github/code-scanning_test.go
+++ b/github/code-scanning_test.go
@@ -96,7 +96,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
 					]
 				},
 				"created_at":"2020-05-06T12:00:00Z",
-				"open":true,
+				"state":"open",
 				"closed_by":null,
 				"closed_at":null,
 				"url":"https://api.github.com/repos/o/r/code-scanning/alerts/25",
@@ -138,7 +138,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
 					]
 				},
 				"created_at":"2020-05-06T12:00:00Z",
-				"open":true,
+				"state":"open",
 				"closed_by":null,
 				"closed_at":null,
 				"url":"https://api.github.com/repos/o/r/code-scanning/alerts/88",
@@ -169,7 +169,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
 				Help:            String("Expression has no effect"),
 			},
 			CreatedAt: &date,
-			Open:      Bool(true),
+			State:     String("open"),
 			ClosedBy:  nil,
 			ClosedAt:  nil,
 			URL:       String("https://api.github.com/repos/o/r/code-scanning/alerts/25"),
@@ -205,7 +205,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
 				Help:            String("Expression has no effect"),
 			},
 			CreatedAt: &date,
-			Open:      Bool(true),
+			State:     String("open"),
 			ClosedBy:  nil,
 			ClosedAt:  nil,
 			URL:       String("https://api.github.com/repos/o/r/code-scanning/alerts/88"),
@@ -288,7 +288,7 @@ func TestActionsService_GetAlert(t *testing.T) {
 					]
 				},      
 				"created_at":"2019-01-02T15:04:05Z",
-				"open":true,
+				"state":"open",
 				"closed_by":null,
 				"closed_at":null,
 				"url":"https://api.github.com/repos/o/r/code-scanning/alerts/88",
@@ -316,7 +316,7 @@ func TestActionsService_GetAlert(t *testing.T) {
 			Help:            String("Expression has no effect"),
 		},
 		CreatedAt: &date,
-		Open:      Bool(true),
+		State:     String("open"),
 		ClosedBy:  nil,
 		ClosedAt:  nil,
 		URL:       String("https://api.github.com/repos/o/r/code-scanning/alerts/88"),
@@ -370,7 +370,7 @@ func TestAlert_Marshal(t *testing.T) {
 			Version: String("v"),
 		},
 		CreatedAt: &Timestamp{referenceTime},
-		Open:      Bool(false),
+		State:     String("fixed"),
 		ClosedBy: &User{
 			Login:     String("l"),
 			ID:        Int64(1),
@@ -395,7 +395,7 @@ func TestAlert_Marshal(t *testing.T) {
 			"version": "v"
 		},
 		"created_at": ` + referenceTimeStr + `,
-		"open": false,
+		"state": "fixed",
 		"closed_by": {
 			"login": "l",
 			"id": 1,
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 86bb6c3e..04bf837a 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -234,16 +234,6 @@ func TestAlert_GetMostRecentInstance(tt *testing.T) {
 	a.GetMostRecentInstance()
 }
 
-func TestAlert_GetOpen(tt *testing.T) {
-	var zeroValue bool
-	a := &Alert{Open: &zeroValue}
-	a.GetOpen()
-	a = &Alert{}
-	a.GetOpen()
-	a = nil
-	a.GetOpen()
-}
-
 func TestAlert_GetRule(tt *testing.T) {
 	a := &Alert{}
 	a.GetRule()
@@ -281,6 +271,16 @@ func TestAlert_GetRuleSeverity(tt *testing.T) {
 	a.GetRuleSeverity()
 }
 
+func TestAlert_GetState(tt *testing.T) {
+	var zeroValue string
+	a := &Alert{State: &zeroValue}
+	a.GetState()
+	a = &Alert{}
+	a.GetState()
+	a = nil
+	a.GetState()
+}
+
 func TestAlert_GetTool(tt *testing.T) {
 	a := &Alert{}
 	a.GetTool()
@@ -519,6 +519,16 @@ func TestAppConfig_GetPEM(tt *testing.T) {
 	a.GetPEM()
 }
 
+func TestAppConfig_GetSlug(tt *testing.T) {
+	var zeroValue string
+	a := &AppConfig{Slug: &zeroValue}
+	a.GetSlug()
+	a = &AppConfig{}
+	a.GetSlug()
+	a = nil
+	a.GetSlug()
+}
+
 func TestAppConfig_GetUpdatedAt(tt *testing.T) {
 	var zeroValue Timestamp
 	a := &AppConfig{UpdatedAt: &zeroValue}
@@ -16599,6 +16609,16 @@ func TestRepoStats_GetTotalWikis(tt *testing.T) {
 	r.GetTotalWikis()
 }
 
+func TestRepoStatus_GetAvatarURL(tt *testing.T) {
+	var zeroValue string
+	r := &RepoStatus{AvatarURL: &zeroValue}
+	r.GetAvatarURL()
+	r = &RepoStatus{}
+	r.GetAvatarURL()
+	r = nil
+	r.GetAvatarURL()
+}
+
 func TestRepoStatus_GetContext(tt *testing.T) {
 	var zeroValue string
 	r := &RepoStatus{Context: &zeroValue}
@@ -16776,6 +16796,16 @@ func TestRule_GetName(tt *testing.T) {
 	r.GetName()
 }
 
+func TestRule_GetSecuritySeverityLevel(tt *testing.T) {
+	var zeroValue string
+	r := &Rule{SecuritySeverityLevel: &zeroValue}
+	r.GetSecuritySeverityLevel()
+	r = &Rule{}
+	r.GetSecuritySeverityLevel()
+	r = nil
+	r.GetSecuritySeverityLevel()
+}
+
 func TestRule_GetSeverity(tt *testing.T) {
 	var zeroValue string
 	r := &Rule{Severity: &zeroValue}
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index 0a852a60..8ebc11cb 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -1372,9 +1372,10 @@ func TestRepoStatus_String(t *testing.T) {
 		TargetURL:   String(""),
 		Description: String(""),
 		Context:     String(""),
+		AvatarURL:   String(""),
 		Creator:     &User{},
 	}
-	want := `github.RepoStatus{ID:0, NodeID:"", URL:"", State:"", TargetURL:"", Description:"", Context:"", Creator:github.User{}}`
+	want := `github.RepoStatus{ID:0, NodeID:"", URL:"", State:"", TargetURL:"", Description:"", Context:"", AvatarURL:"", Creator:github.User{}}`
 	if got := v.String(); got != want {
 		t.Errorf("RepoStatus.String = %v, want %v", got, want)
 	}
diff --git a/github/github_test.go b/github/github_test.go
index 1eb0dba7..d2240558 100644
--- a/github/github_test.go
+++ b/github/github_test.go
@@ -232,6 +232,14 @@ func TestNewClient(t *testing.T) {
 	}
 }
 
+func TestClient(t *testing.T) {
+	c := NewClient(nil)
+	c2 := c.Client()
+	if c.client == c2 {
+		t.Error("Client returned same http.Client, but should be different")
+	}
+}
+
 func TestNewEnterpriseClient(t *testing.T) {
 	baseURL := "https://custom-url/api/v3/"
 	uploadURL := "https://custom-upload-url/api/uploads/"