Repository: google/go-github
Pull request #1256 (2019-08-20 15:39:04)

Add missing `CreatedAt` field in users_keys class

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1256?src=pr&el=h1) Report
> Merging [#1256](https://codecov.io/gh/google/go-github/pull/1256?src=pr&el=desc) into [master](https://codecov.io/gh/google/go-github/commit/da8b749b25d68690af6239660210ab1915b029cd?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/1256/graphs/tree.svg?width=650&token=EgYjGjZlI0&height=150&src=pr)](https://codecov.io/gh/google/go-github/pull/1256?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1256   +/-   ##
=======================================
  Coverage   73.42%   73.42%           
=======================================
  Files          86       86           
  Lines        6040     6040           
=======================================
  Hits         4435     4435           
  Misses        836      836           
  Partials      769      769
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1256?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [github/users\_keys.go](https://codecov.io/gh/google/go-github/pull/1256/diff?src=pr&el=tree#diff-Z2l0aHViL3VzZXJzX2tleXMuZ28=) | `68.88% <ø> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1256?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/1256?src=pr&el=footer). Last update [da8b749...e98736d](https://codecov.io/gh/google/go-github/pull/1256?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 7c89cb60..434cc938 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -4612,6 +4612,14 @@ func (i *IssueStats) GetTotalIssues() int {
 	return *i.TotalIssues
 }
 
+// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
+func (k *Key) GetCreatedAt() Timestamp {
+	if k == nil || k.CreatedAt == nil {
+		return Timestamp{}
+	}
+	return *k.CreatedAt
+}
+
 // GetID returns the ID field if it's non-nil, zero value otherwise.
 func (k *Key) GetID() int64 {
 	if k == nil || k.ID == nil {
diff --git a/github/users_keys.go b/github/users_keys.go
index ddc832a1..39a4f54d 100644
--- a/github/users_keys.go
+++ b/github/users_keys.go
@@ -12,11 +12,12 @@ import (
 
 // Key represents a public SSH key used to authenticate a user or deploy script.
 type Key struct {
-	ID       *int64  `json:"id,omitempty"`
-	Key      *string `json:"key,omitempty"`
-	URL      *string `json:"url,omitempty"`
-	Title    *string `json:"title,omitempty"`
-	ReadOnly *bool   `json:"read_only,omitempty"`
+	ID        *int64     `json:"id,omitempty"`
+	Key       *string    `json:"key,omitempty"`
+	URL       *string    `json:"url,omitempty"`
+	Title     *string    `json:"title,omitempty"`
+	ReadOnly  *bool      `json:"read_only,omitempty"`
+	CreatedAt *Timestamp `json:"created_at,omitempty"`
 }
 
 func (k Key) String() string {


Test patch:
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index c91f7b5a..2e7b285e 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -623,13 +623,14 @@ func TestIssueStats_String(t *testing.T) {
 
 func TestKey_String(t *testing.T) {
 	v := Key{
-		ID:       Int64(0),
-		Key:      String(""),
-		URL:      String(""),
-		Title:    String(""),
-		ReadOnly: Bool(false),
+		ID:        Int64(0),
+		Key:       String(""),
+		URL:       String(""),
+		Title:     String(""),
+		ReadOnly:  Bool(false),
+		CreatedAt: &Timestamp{},
 	}
-	want := `github.Key{ID:0, Key:"", URL:"", Title:"", ReadOnly:false}`
+	want := `github.Key{ID:0, Key:"", URL:"", Title:"", ReadOnly:false, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}`
 	if got := v.String(); got != want {
 		t.Errorf("Key.String = %v, want %v", got, want)
 	}