Browse Source

switch singular GitHub struct fields to pointers

Like a51d6b4303, this change makes me sad, mainly because it is a
breaking change for all clients, and makes common tasks like reading
data out of structs slightly more work, with no direct benefit. Notably,
developers will need to make sure and check for nil values before trying
to dereference these pointers.  Sadly, the change is still necessary, as
is more fully explained in issue #19.  We can make the nil pointer
checks a little easier by adding some Get* funcs like goprotobuf does.

I spent a lot of time over the last few weeks exploring this change
(switching fields to pointers) versus the much larger change of using
protocol buffers for all GitHub data types.  While the goprotobuf
library is very mature and feature-rich (it's used heavily inside of
Google), it's the wrong tool for this task, since we're not actually
using the proto wire format.  While it does address the immediate
concern in #19, it makes way too many other things terribly awkward.

One of the biggest drawbacks of this change is that it will make the
string output from fmt.Printf("%v") next to useless, since all pointer
values are displayed as their memory address.  To handle that, I'll be
writing a custom String() function for these structs that is heavily
inspired by goprotobuf and internals from go's fmt package.
Will Norris 13 years ago
parent
commit
3072d069f2
43 changed files with 327 additions and 301 deletions
  1. +18
    -18
      github/activity_events.go
  2. +11
    -11
      github/activity_events_test.go
  3. +2
    -2
      github/activity_star_test.go
  4. +11
    -11
      github/gists.go
  5. +3
    -3
      github/gists_comments.go
  6. +8
    -14
      github/gists_comments_test.go
  7. +20
    -20
      github/gists_test.go
  8. +4
    -4
      github/git_commits.go
  9. +3
    -3
      github/git_commits_test.go
  10. +6
    -6
      github/git_trees.go
  11. +12
    -12
      github/git_trees_test.go
  12. +25
    -0
      github/github.go
  13. +1
    -1
      github/github_test.go
  14. +5
    -5
      github/issues.go
  15. +1
    -1
      github/issues_assignees_test.go
  16. +2
    -2
      github/issues_comments.go
  17. +7
    -7
      github/issues_comments_test.go
  18. +3
    -3
      github/issues_labels.go
  19. +10
    -10
      github/issues_labels_test.go
  20. +16
    -9
      github/issues_test.go
  21. +5
    -5
      github/orgs.go
  22. +2
    -2
      github/orgs_members_test.go
  23. +7
    -7
      github/orgs_teams.go
  24. +8
    -8
      github/orgs_teams_test.go
  25. +5
    -5
      github/orgs_test.go
  26. +11
    -11
      github/pulls.go
  27. +5
    -5
      github/pulls_comments.go
  28. +7
    -7
      github/pulls_comments_test.go
  29. +6
    -6
      github/pulls_test.go
  30. +3
    -3
      github/repos.go
  31. +1
    -1
      github/repos_collaborators_test.go
  32. +9
    -9
      github/repos_comments.go
  33. +8
    -8
      github/repos_comments_test.go
  34. +2
    -2
      github/repos_forks_test.go
  35. +22
    -22
      github/repos_hooks.go
  36. +6
    -6
      github/repos_hooks_test.go
  37. +4
    -4
      github/repos_statuses.go
  38. +3
    -3
      github/repos_statuses_test.go
  39. +10
    -10
      github/repos_test.go
  40. +8
    -8
      github/search.go
  41. +8
    -8
      github/search_test.go
  42. +14
    -14
      github/users.go
  43. +5
    -5
      github/users_test.go

+ 18
- 18
github/activity_events.go View File

@ -15,24 +15,24 @@ import (
// Event represents a GitHub event.
type Event struct {
Type string `json:"type,omitempty"`
Public bool `json:"public"`
RawPayload json.RawMessage `json:"payload,omitempty"`
Repo *Repository `json:"repo,omitempty"`
Actor *User `json:"actor,omitempty"`
Org *Organization `json:"org,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
ID string `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Public *bool `json:"public"`
RawPayload *json.RawMessage `json:"payload,omitempty"`
Repo *Repository `json:"repo,omitempty"`
Actor *User `json:"actor,omitempty"`
Org *Organization `json:"org,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
ID *string `json:"id,omitempty"`
}
// Payload returns the parsed event payload. For recognized event types
// (PushEvent), a value of the corresponding struct type will be returned.
func (e *Event) Payload() (payload interface{}) {
switch e.Type {
switch *e.Type {
case "PushEvent":
payload = &PushEvent{}
}
if err := json.Unmarshal(e.RawPayload, &payload); err != nil {
if err := json.Unmarshal(*e.RawPayload, &payload); err != nil {
panic(err.Error())
}
return payload
@ -42,20 +42,20 @@ func (e *Event) Payload() (payload interface{}) {
//
// GitHub API docs: http://developer.github.com/v3/activity/events/types/#pushevent
type PushEvent struct {
PushID int `json:"push_id,omitempty"`
Head string `json:"head,omitempty"`
Ref string `json:"ref,omitempty"`
Size int `json:"ref,omitempty"`
PushID *int `json:"push_id,omitempty"`
Head *string `json:"head,omitempty"`
Ref *string `json:"ref,omitempty"`
Size *int `json:"ref,omitempty"`
Commits []PushEventCommit `json:"commits,omitempty"`
}
// PushEventCommit represents a git commit in a GitHub PushEvent.
type PushEventCommit struct {
SHA string `json:"sha,omitempty"`
Message string `json:"message,omitempty"`
SHA *string `json:"sha,omitempty"`
Message *string `json:"message,omitempty"`
Author *CommitAuthor `json:"author,omitempty"`
URL string `json:"url,omitempty"`
Distinct bool `json:"distinct"`
URL *string `json:"url,omitempty"`
Distinct *bool `json:"distinct"`
}
// List public events.


+ 11
- 11
github/activity_events_test.go View File

@ -31,7 +31,7 @@ func TestActivityService_ListPublicEvents(t *testing.T) {
t.Errorf("Activities.ListPublicEvents returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Activities.ListPublicEvents returned %+v, want %+v", events, want)
}
@ -55,7 +55,7 @@ func TestActivityService_ListRepositoryEvents(t *testing.T) {
t.Errorf("Activities.ListRepositoryEvents returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Activities.ListRepositoryEvents returned %+v, want %+v", events, want)
}
@ -79,7 +79,7 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) {
t.Errorf("Activities.ListIssueEventsForRepository returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Activities.ListIssueEventsForRepository returned %+v, want %+v", events, want)
}
@ -103,7 +103,7 @@ func TestActivityService_ListEventsForRepoNetwork(t *testing.T) {
t.Errorf("Activities.ListEventsForRepoNetwork returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Activities.ListEventsForRepoNetwork returned %+v, want %+v", events, want)
}
@ -127,7 +127,7 @@ func TestActivityService_ListPublicEventsForOrganization(t *testing.T) {
t.Errorf("Activities.ListPublicEventsForOrganization returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Activities.ListPublicEventsForOrganization returned %+v, want %+v", events, want)
}
@ -151,7 +151,7 @@ func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) {
t.Errorf("Events.ListPerformedByUser returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Events.ListPerformedByUser returned %+v, want %+v", events, want)
}
@ -171,7 +171,7 @@ func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) {
t.Errorf("Events.ListPerformedByUser returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Events.ListPerformedByUser returned %+v, want %+v", events, want)
}
@ -195,7 +195,7 @@ func TestActivityService_ListEventsRecievedByUser_all(t *testing.T) {
t.Errorf("Events.ListRecievedByUser returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Events.ListRecievedUser returned %+v, want %+v", events, want)
}
@ -215,7 +215,7 @@ func TestActivityService_ListEventsRecievedByUser_publicOnly(t *testing.T) {
t.Errorf("Events.ListRecievedByUser returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Events.ListRecievedByUser returned %+v, want %+v", events, want)
}
@ -235,7 +235,7 @@ func TestActivityService_ListUserEventsForOrganization(t *testing.T) {
t.Errorf("Activities.ListUserEventsForOrganization returned error: %v", err)
}
want := []Event{{ID: "1"}, {ID: "2"}}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Activities.ListUserEventsForOrganization returned %+v, want %+v", events, want)
}
@ -248,7 +248,7 @@ func TestActivity_EventPayload_typed(t *testing.T) {
t.Fatalf("Unmarshal Event returned error: %v", err)
}
want := &PushEvent{PushID: 1}
want := &PushEvent{PushID: Int(1)}
if !reflect.DeepEqual(event.Payload(), want) {
t.Errorf("Event Payload returned %+v, want %+v", event.Payload(), want)
}


+ 2
- 2
github/activity_star_test.go View File

@ -26,7 +26,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) {
t.Errorf("Activity.ListStarred returned error: %v", err)
}
want := []Repository{{ID: 1}}
want := []Repository{{ID: Int(1)}}
if !reflect.DeepEqual(repos, want) {
t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
}
@ -52,7 +52,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) {
t.Errorf("Activity.ListStarred returned error: %v", err)
}
want := []Repository{{ID: 2}}
want := []Repository{{ID: Int(2)}}
if !reflect.DeepEqual(repos, want) {
t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
}


+ 11
- 11
github/gists.go View File

@ -21,15 +21,15 @@ type GistsService struct {
// Gist represents a GitHub's gist.
type Gist struct {
ID string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
Public bool `json:"public,omitempty"`
ID *string `json:"id,omitempty"`
Description *string `json:"description,omitempty"`
Public *bool `json:"public,omitempty"`
User *User `json:"user,omitempty"`
Files map[GistFilename]GistFile `json:"files,omitempty"`
Comments int `json:"comments,omitempty"`
HTMLURL string `json:"html_url,omitempty"`
GitPullURL string `json:"git_pull_url,omitempty"`
GitPushURL string `json:"git_push_url,omitempty"`
Comments *int `json:"comments,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
GitPullURL *string `json:"git_pull_url,omitempty"`
GitPushURL *string `json:"git_push_url,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
}
@ -38,10 +38,10 @@ type GistFilename string
// GistFile represents a file on a gist.
type GistFile struct {
Size int `json:"size,omitempty"`
Filename GistFilename `json:"filename,omitempty"`
RawURL string `json:"raw_url,omitempty"`
Content string `json:"content,omitempty"`
Size *int `json:"size,omitempty"`
Filename *string `json:"filename,omitempty"`
RawURL *string `json:"raw_url,omitempty"`
Content *string `json:"content,omitempty"`
}
// GistListOptions specifies the optional parameters to the


+ 3
- 3
github/gists_comments.go View File

@ -12,9 +12,9 @@ import (
// GistComment represents a Gist comment.
type GistComment struct {
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
Body string `json:"body,omitempty"`
ID *int `json:"id,omitempty"`
URL *string `json:"url,omitempty"`
Body *string `json:"body,omitempty"`
User *User `json:"user,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
}


+ 8
- 14
github/gists_comments_test.go View File

@ -28,7 +28,7 @@ func TestGistsService_ListComments(t *testing.T) {
t.Errorf("Gists.Comments returned error: %v", err)
}
want := []GistComment{{ID: 1}}
want := []GistComment{{ID: Int(1)}}
if !reflect.DeepEqual(comments, want) {
t.Errorf("Gists.ListComments returned %+v, want %+v", comments, want)
}
@ -49,7 +49,7 @@ func TestGistsService_GetComment(t *testing.T) {
t.Errorf("Gists.GetComment returned error: %v", err)
}
want := &GistComment{ID: 1}
want := &GistComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("Gists.GetComment returned %+v, want %+v", comment, want)
}
@ -59,10 +59,7 @@ func TestGistsService_CreateComment(t *testing.T) {
setup()
defer teardown()
input := &GistComment{
ID: 1,
Body: "This is the comment body.",
}
input := &GistComment{ID: Int(1), Body: String("b")}
mux.HandleFunc("/gists/1/comments", func(w http.ResponseWriter, r *http.Request) {
v := new(GistComment)
@ -73,7 +70,7 @@ func TestGistsService_CreateComment(t *testing.T) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
fmt.Fprint(w, `{"id":1, "body":"b", "url":"u", "user":{"id":2}}`)
fmt.Fprint(w, `{"id":1}`)
})
comment, _, err := client.Gists.CreateComment("1", input)
@ -81,7 +78,7 @@ func TestGistsService_CreateComment(t *testing.T) {
t.Errorf("Gists.CreateComment returned error: %v", err)
}
want := &GistComment{ID: 1, Body: "b", URL: "u", User: &User{ID: 2}}
want := &GistComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("Gists.CreateComment returned %+v, want %+v", comment, want)
}
@ -91,10 +88,7 @@ func TestGistsService_EditComment(t *testing.T) {
setup()
defer teardown()
input := &GistComment{
ID: 1,
Body: "New comment.",
}
input := &GistComment{ID: Int(1), Body: String("b")}
mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) {
v := new(GistComment)
@ -105,7 +99,7 @@ func TestGistsService_EditComment(t *testing.T) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
fmt.Fprint(w, `{"id":1, "body":"b", "url":"u", "user":{"id":2}}`)
fmt.Fprint(w, `{"id":1}`)
})
comment, _, err := client.Gists.EditComment("1", 2, input)
@ -113,7 +107,7 @@ func TestGistsService_EditComment(t *testing.T) {
t.Errorf("Gists.EditComment returned error: %v", err)
}
want := &GistComment{ID: 1, Body: "b", URL: "u", User: &User{ID: 2}}
want := &GistComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("Gists.EditComment returned %+v, want %+v", comment, want)
}


+ 20
- 20
github/gists_test.go View File

@ -35,7 +35,7 @@ func TestGistsService_List(t *testing.T) {
t.Errorf("Gists.List returned error: %v", err)
}
want := []Gist{{ID: "1"}}
want := []Gist{{ID: String("1")}}
if !reflect.DeepEqual(gists, want) {
t.Errorf("Gists.List returned %+v, want %+v", gists, want)
}
@ -55,7 +55,7 @@ func TestGistsService_List_withEmptyUser(t *testing.T) {
t.Errorf("Gists.List returned error: %v", err)
}
want := []Gist{{ID: "1"}}
want := []Gist{{ID: String("1")}}
if !reflect.DeepEqual(gists, want) {
t.Errorf("Gists.List returned %+v, want %+v", gists, want)
}
@ -82,7 +82,7 @@ func TestGistsService_ListAll(t *testing.T) {
t.Errorf("Gists.ListAll returned error: %v", err)
}
want := []Gist{{ID: "1"}}
want := []Gist{{ID: String("1")}}
if !reflect.DeepEqual(gists, want) {
t.Errorf("Gists.ListAll returned %+v, want %+v", gists, want)
}
@ -109,7 +109,7 @@ func TestGistsService_ListStarred(t *testing.T) {
t.Errorf("Gists.ListStarred returned error: %v", err)
}
want := []Gist{{ID: "1"}}
want := []Gist{{ID: String("1")}}
if !reflect.DeepEqual(gists, want) {
t.Errorf("Gists.ListStarred returned %+v, want %+v", gists, want)
}
@ -130,7 +130,7 @@ func TestGistsService_Get(t *testing.T) {
t.Errorf("Gists.Get returned error: %v", err)
}
want := &Gist{ID: "1"}
want := &Gist{ID: String("1")}
if !reflect.DeepEqual(gist, want) {
t.Errorf("Gists.Get returned %+v, want %+v", gist, want)
}
@ -141,10 +141,10 @@ func TestGistsService_Create(t *testing.T) {
defer teardown()
input := &Gist{
Description: "Gist description",
Public: false,
Description: String("Gist description"),
Public: Bool(false),
Files: map[GistFilename]GistFile{
"test.txt": GistFile{Content: "Gist file content"},
"test.txt": GistFile{Content: String("Gist file content")},
},
}
@ -177,11 +177,11 @@ func TestGistsService_Create(t *testing.T) {
}
want := &Gist{
ID: "1",
Description: "Gist description",
Public: false,
ID: String("1"),
Description: String("Gist description"),
Public: Bool(false),
Files: map[GistFilename]GistFile{
"test.txt": GistFile{Filename: "test.txt"},
"test.txt": GistFile{Filename: String("test.txt")},
},
}
if !reflect.DeepEqual(gist, want) {
@ -194,9 +194,9 @@ func TestGistsService_Edit(t *testing.T) {
defer teardown()
input := &Gist{
Description: "New description",
Description: String("New description"),
Files: map[GistFilename]GistFile{
"new.txt": GistFile{Content: "new file content"},
"new.txt": GistFile{Content: String("new file content")},
},
}
@ -232,12 +232,12 @@ func TestGistsService_Edit(t *testing.T) {
}
want := &Gist{
ID: "1",
Description: "new description",
Public: false,
ID: String("1"),
Description: String("new description"),
Public: Bool(false),
Files: map[GistFilename]GistFile{
"test.txt": GistFile{Filename: "test.txt"},
"new.txt": GistFile{Filename: "new.txt"},
"test.txt": GistFile{Filename: String("test.txt")},
"new.txt": GistFile{Filename: String("new.txt")},
},
}
if !reflect.DeepEqual(gist, want) {
@ -338,7 +338,7 @@ func TestGistsService_Fork(t *testing.T) {
t.Errorf("Gists.Fork returned error: %v", err)
}
want := &Gist{ID: "2"}
want := &Gist{ID: String("2")}
if !reflect.DeepEqual(gist, want) {
t.Errorf("Gists.Fork returned %+v, want %+v", gist, want)
}


+ 4
- 4
github/git_commits.go View File

@ -12,10 +12,10 @@ import (
// Commit represents a GitHub commit.
type Commit struct {
SHA string `json:"sha,omitempty"`
SHA *string `json:"sha,omitempty"`
Author *CommitAuthor `json:"author,omitempty"`
Committer *CommitAuthor `json:"committer,omitempty"`
Message string `json:"message,omitempty"`
Message *string `json:"message,omitempty"`
Tree *Tree `json:"tree,omitempty"`
Parents []Commit `json:"parents,omitempty"`
}
@ -24,8 +24,8 @@ type Commit struct {
// author may not correspond to a GitHub User.
type CommitAuthor struct {
Date *time.Time `json:"date,omitempty"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
Email *string `json:"email,omitempty"`
}
// GetCommit fetchs the Commit object for a given SHA.


+ 3
- 3
github/git_commits_test.go View File

@ -27,7 +27,7 @@ func TestGitService_GetCommit(t *testing.T) {
t.Errorf("Git.GetCommit returned error: %v", err)
}
want := &Commit{SHA: "s", Message: "m", Author: &CommitAuthor{Name: "n"}}
want := &Commit{SHA: String("s"), Message: String("m"), Author: &CommitAuthor{Name: String("n")}}
if !reflect.DeepEqual(commit, want) {
t.Errorf("Git.GetCommit returned %+v, want %+v", commit, want)
}
@ -37,7 +37,7 @@ func TestGitService_CreateCommit(t *testing.T) {
setup()
defer teardown()
input := &Commit{Message: "m", Tree: &Tree{SHA: "t"}}
input := &Commit{Message: String("m"), Tree: &Tree{SHA: String("t")}}
mux.HandleFunc("/repos/o/r/git/commits", func(w http.ResponseWriter, r *http.Request) {
v := new(Commit)
@ -55,7 +55,7 @@ func TestGitService_CreateCommit(t *testing.T) {
t.Errorf("Git.CreateCommit returned error: %v", err)
}
want := &Commit{SHA: "s"}
want := &Commit{SHA: String("s")}
if !reflect.DeepEqual(commit, want) {
t.Errorf("Git.CreateCommit returned %+v, want %+v", commit, want)
}


+ 6
- 6
github/git_trees.go View File

@ -9,7 +9,7 @@ import "fmt"
// Tree represents a GitHub tree.
type Tree struct {
SHA string `json:"sha,omitempty"`
SHA *string `json:"sha,omitempty"`
Entries []TreeEntry `json:"tree,omitempty"`
}
@ -17,11 +17,11 @@ type Tree struct {
// represent either a blob, a commit (in the case of a submodule), or another
// tree.
type TreeEntry struct {
SHA string `json:"sha,omitempty"`
Path string `json:"path,omitempty"`
Mode string `json:"mode,omitempty"`
Type string `json:"type,omitempty"`
Size int `json:"size,omitempty"`
SHA *string `json:"sha,omitempty"`
Path *string `json:"path,omitempty"`
Mode *string `json:"mode,omitempty"`
Type *string `json:"type,omitempty"`
Size *int `json:"size,omitempty"`
}
// GetTree fetches the Tree object for a given sha hash from a repository.


+ 12
- 12
github/git_trees_test.go View File

@ -33,10 +33,10 @@ func TestGitService_GetTree(t *testing.T) {
}
want := Tree{
SHA: "s",
SHA: String("s"),
Entries: []TreeEntry{
TreeEntry{
Type: "blob",
Type: String("blob"),
},
},
}
@ -51,10 +51,10 @@ func TestGitService_CreateTree(t *testing.T) {
input := []TreeEntry{
TreeEntry{
Path: "file.rb",
Mode: "100644",
Type: "blob",
SHA: "7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b",
Path: String("file.rb"),
Mode: String("100644"),
Type: String("blob"),
SHA: String("7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"),
},
}
@ -94,14 +94,14 @@ func TestGitService_CreateTree(t *testing.T) {
}
want := Tree{
"cd8274d15fa3ae2ab983129fb037999f264ba9a7",
String("cd8274d15fa3ae2ab983129fb037999f264ba9a7"),
[]TreeEntry{
TreeEntry{
Path: "file.rb",
Mode: "100644",
Type: "blob",
Size: 132,
SHA: "7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b",
Path: String("file.rb"),
Mode: String("100644"),
Type: String("blob"),
Size: Int(132),
SHA: String("7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"),
},
},
}


+ 25
- 0
github/github.go View File

@ -438,3 +438,28 @@ func cloneRequest(r *http.Request) *http.Request {
}
return r2
}
// Bool is a helper routine that allocates a new bool value
// to store v and returns a pointer to it.
func Bool(v bool) *bool {
p := new(bool)
*p = v
return p
}
// Int is a helper routine that allocates a new int32 value
// to store v and returns a pointer to it, but unlike Int32
// its argument value is an int.
func Int(v int) *int {
p := new(int)
*p = v
return p
}
// String is a helper routine that allocates a new string value
// to store v and returns a pointer to it.
func String(v string) *string {
p := new(string)
*p = v
return p
}

+ 1
- 1
github/github_test.go View File

@ -93,7 +93,7 @@ func TestNewRequest(t *testing.T) {
c := NewClient(nil)
inURL, outURL := "/foo", defaultBaseURL+"foo"
inBody, outBody := &User{Login: "l"}, `{"login":"l"}`+"\n"
inBody, outBody := &User{Login: String("l")}, `{"login":"l"}`+"\n"
req, _ := c.NewRequest("GET", inURL, inBody)
// test that relative URL was expanded


+ 5
- 5
github/issues.go View File

@ -23,14 +23,14 @@ type IssuesService struct {
// Issue represents a GitHub issue on a repository.
type Issue struct {
Number int `json:"number,omitempty"`
State string `json:"state,omitempty"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
Number *int `json:"number,omitempty"`
State *string `json:"state,omitempty"`
Title *string `json:"title,omitempty"`
Body *string `json:"body,omitempty"`
User *User `json:"user,omitempty"`
Labels []Label `json:"labels,omitempty"`
Assignee *User `json:"assignee,omitempty"`
Comments int `json:"comments,omitempty"`
Comments *int `json:"comments,omitempty"`
ClosedAt *time.Time `json:"closed_at,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`


+ 1
- 1
github/issues_assignees_test.go View File

@ -26,7 +26,7 @@ func TestIssuesService_ListAssignees(t *testing.T) {
t.Errorf("Issues.List returned error: %v", err)
}
want := []User{{ID: 1}}
want := []User{{ID: Int(1)}}
if !reflect.DeepEqual(assignees, want) {
t.Errorf("Issues.ListAssignees returned %+v, want %+v", assignees, want)
}


+ 2
- 2
github/issues_comments.go View File

@ -13,8 +13,8 @@ import (
// IssueComment represents a comment left on an issue.
type IssueComment struct {
ID int `json:"id,omitempty"`
Body string `json:"body,omitempty"`
ID *int `json:"id,omitempty"`
Body *string `json:"body,omitempty"`
User *User `json:"user,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`


+ 7
- 7
github/issues_comments_test.go View File

@ -36,7 +36,7 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) {
t.Errorf("Issues.ListComments returned error: %v", err)
}
want := []IssueComment{{ID: 1}}
want := []IssueComment{{ID: Int(1)}}
if !reflect.DeepEqual(comments, want) {
t.Errorf("Issues.ListComments returned %+v, want %+v", comments, want)
}
@ -56,7 +56,7 @@ func TestIssuesService_ListComments_specificIssue(t *testing.T) {
t.Errorf("Issues.ListComments returned error: %v", err)
}
want := []IssueComment{{ID: 1}}
want := []IssueComment{{ID: Int(1)}}
if !reflect.DeepEqual(comments, want) {
t.Errorf("Issues.ListComments returned %+v, want %+v", comments, want)
}
@ -81,7 +81,7 @@ func TestIssuesService_GetComment(t *testing.T) {
t.Errorf("Issues.GetComment returned error: %v", err)
}
want := &IssueComment{ID: 1}
want := &IssueComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("Issues.GetComment returned %+v, want %+v", comment, want)
}
@ -96,7 +96,7 @@ func TestIssuesService_CreateComment(t *testing.T) {
setup()
defer teardown()
input := &IssueComment{Body: "b"}
input := &IssueComment{Body: String("b")}
mux.HandleFunc("/repos/o/r/issues/1/comments", func(w http.ResponseWriter, r *http.Request) {
v := new(IssueComment)
@ -115,7 +115,7 @@ func TestIssuesService_CreateComment(t *testing.T) {
t.Errorf("Issues.CreateComment returned error: %v", err)
}
want := &IssueComment{ID: 1}
want := &IssueComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("Issues.CreateComment returned %+v, want %+v", comment, want)
}
@ -130,7 +130,7 @@ func TestIssuesService_EditComment(t *testing.T) {
setup()
defer teardown()
input := &IssueComment{Body: "b"}
input := &IssueComment{Body: String("b")}
mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) {
v := new(IssueComment)
@ -149,7 +149,7 @@ func TestIssuesService_EditComment(t *testing.T) {
t.Errorf("Issues.EditComment returned error: %v", err)
}
want := &IssueComment{ID: 1}
want := &IssueComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("Issues.EditComment returned %+v, want %+v", comment, want)
}


+ 3
- 3
github/issues_labels.go View File

@ -9,9 +9,9 @@ import "fmt"
// Label represents a GitHib label on an Issue
type Label struct {
URL string `json:"url,omitempty"`
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`
URL *string `json:"url,omitempty"`
Name *string `json:"name,omitempty"`
Color *string `json:"color,omitempty"`
}
func (label Label) String() string {


+ 10
- 10
github/issues_labels_test.go View File

@ -27,7 +27,7 @@ func TestIssuesService_ListLabels(t *testing.T) {
t.Errorf("Issues.ListLabels returned error: %v", err)
}
want := []Label{{Name: "a"}, {Name: "b"}}
want := []Label{{Name: String("a")}, {Name: String("b")}}
if !reflect.DeepEqual(labels, want) {
t.Errorf("Issues.ListLabels returned %+v, want %+v", labels, want)
}
@ -47,7 +47,7 @@ func TestIssuesService_GetLabel(t *testing.T) {
t.Errorf("Issues.GetLabel returned error: %v", err)
}
want := &Label{URL: "u", Name: "n", Color: "c"}
want := &Label{URL: String("u"), Name: String("n"), Color: String("c")}
if !reflect.DeepEqual(label, want) {
t.Errorf("Issues.GetLabel returned %+v, want %+v", label, want)
}
@ -57,7 +57,7 @@ func TestIssuesService_CreateLabel(t *testing.T) {
setup()
defer teardown()
input := &Label{Name: "n"}
input := &Label{Name: String("n")}
mux.HandleFunc("/repos/o/r/labels", func(w http.ResponseWriter, r *http.Request) {
v := new(Label)
@ -76,7 +76,7 @@ func TestIssuesService_CreateLabel(t *testing.T) {
t.Errorf("Issues.CreateLabel returned error: %v", err)
}
want := &Label{URL: "u"}
want := &Label{URL: String("u")}
if !reflect.DeepEqual(label, want) {
t.Errorf("Issues.CreateLabel returned %+v, want %+v", label, want)
}
@ -86,7 +86,7 @@ func TestIssuesService_EditLabel(t *testing.T) {
setup()
defer teardown()
input := &Label{Name: "z"}
input := &Label{Name: String("z")}
mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) {
v := new(Label)
@ -105,7 +105,7 @@ func TestIssuesService_EditLabel(t *testing.T) {
t.Errorf("Issues.EditLabel returned error: %v", err)
}
want := &Label{URL: "u"}
want := &Label{URL: String("u")}
if !reflect.DeepEqual(label, want) {
t.Errorf("Issues.EditLabel returned %+v, want %+v", label, want)
}
@ -139,7 +139,7 @@ func TestIssuesService_ListLabelsByIssue(t *testing.T) {
t.Errorf("Issues.ListLabelsByIssue returned error: %v", err)
}
want := []Label{{Name: "a"}, {Name: "b"}}
want := []Label{{Name: String("a")}, {Name: String("b")}}
if !reflect.DeepEqual(labels, want) {
t.Errorf("Issues.ListLabelsByIssue returned %+v, want %+v", labels, want)
}
@ -168,7 +168,7 @@ func TestIssuesService_AddLabelsToIssue(t *testing.T) {
t.Errorf("Issues.AddLabelsToIssue returned error: %v", err)
}
want := []Label{{URL: "u"}}
want := []Label{{URL: String("u")}}
if !reflect.DeepEqual(labels, want) {
t.Errorf("Issues.AddLabelsToIssue returned %+v, want %+v", labels, want)
}
@ -211,7 +211,7 @@ func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) {
t.Errorf("Issues.ReplaceLabelsForIssue returned error: %v", err)
}
want := []Label{{URL: "u"}}
want := []Label{{URL: String("u")}}
if !reflect.DeepEqual(labels, want) {
t.Errorf("Issues.ReplaceLabelsForIssue returned %+v, want %+v", labels, want)
}
@ -245,7 +245,7 @@ func TestIssuesService_ListLabelsForMilestone(t *testing.T) {
t.Errorf("Issues.ListLabelsForMilestone returned error: %v", err)
}
want := []Label{{Name: "a"}, {Name: "b"}}
want := []Label{{Name: String("a")}, {Name: String("b")}}
if !reflect.DeepEqual(labels, want) {
t.Errorf("Issues.ListLabelsForMilestone returned %+v, want %+v", labels, want)
}


+ 16
- 9
github/issues_test.go View File

@ -43,7 +43,7 @@ func TestIssuesService_List_all(t *testing.T) {
t.Errorf("Issues.List returned error: %v", err)
}
want := []Issue{{Number: 1}}
want := []Issue{{Number: Int(1)}}
if !reflect.DeepEqual(issues, want) {
t.Errorf("Issues.List returned %+v, want %+v", issues, want)
}
@ -63,7 +63,7 @@ func TestIssuesService_List_owned(t *testing.T) {
t.Errorf("Issues.List returned error: %v", err)
}
want := []Issue{{Number: 1}}
want := []Issue{{Number: Int(1)}}
if !reflect.DeepEqual(issues, want) {
t.Errorf("Issues.List returned %+v, want %+v", issues, want)
}
@ -83,7 +83,7 @@ func TestIssuesService_ListByOrg(t *testing.T) {
t.Errorf("Issues.ListByOrg returned error: %v", err)
}
want := []Issue{{Number: 1}}
want := []Issue{{Number: Int(1)}}
if !reflect.DeepEqual(issues, want) {
t.Errorf("Issues.List returned %+v, want %+v", issues, want)
}
@ -123,7 +123,7 @@ func TestIssuesService_ListByRepo(t *testing.T) {
t.Errorf("Issues.ListByOrg returned error: %v", err)
}
want := []Issue{{Number: 1}}
want := []Issue{{Number: Int(1)}}
if !reflect.DeepEqual(issues, want) {
t.Errorf("Issues.List returned %+v, want %+v", issues, want)
}
@ -148,7 +148,14 @@ func TestIssuesService_Get(t *testing.T) {
t.Errorf("Issues.Get returned error: %v", err)
}
want := &Issue{Number: 1, Labels: []Label{{URL: "u", Name: "n", Color: "c"}}}
want := &Issue{
Number: Int(1),
Labels: []Label{Label{
URL: String("u"),
Name: String("n"),
Color: String("c"),
}},
}
if !reflect.DeepEqual(issue, want) {
t.Errorf("Issues.Get returned %+v, want %+v", issue, want)
}
@ -163,7 +170,7 @@ func TestIssuesService_Create(t *testing.T) {
setup()
defer teardown()
input := &Issue{Title: "t"}
input := &Issue{Title: String("t")}
mux.HandleFunc("/repos/o/r/issues", func(w http.ResponseWriter, r *http.Request) {
v := new(Issue)
@ -182,7 +189,7 @@ func TestIssuesService_Create(t *testing.T) {
t.Errorf("Issues.Create returned error: %v", err)
}
want := &Issue{Number: 1}
want := &Issue{Number: Int(1)}
if !reflect.DeepEqual(issue, want) {
t.Errorf("Issues.Create returned %+v, want %+v", issue, want)
}
@ -197,7 +204,7 @@ func TestIssuesService_Edit(t *testing.T) {
setup()
defer teardown()
input := &Issue{Title: "t"}
input := &Issue{Title: String("t")}
mux.HandleFunc("/repos/o/r/issues/1", func(w http.ResponseWriter, r *http.Request) {
v := new(Issue)
@ -216,7 +223,7 @@ func TestIssuesService_Edit(t *testing.T) {
t.Errorf("Issues.Edit returned error: %v", err)
}
want := &Issue{Number: 1}
want := &Issue{Number: Int(1)}
if !reflect.DeepEqual(issue, want) {
t.Errorf("Issues.Edit returned %+v, want %+v", issue, want)
}


+ 5
- 5
github/orgs.go View File

@ -22,11 +22,11 @@ type OrganizationsService struct {
// Organization represents a GitHub organization account.
type Organization struct {
Login string `json:"login,omitempty"`
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
Location string `json:"location,omitempty"`
Login *string `json:"login,omitempty"`
ID *int `json:"id,omitempty"`
URL *string `json:"url,omitempty"`
AvatarURL *string `json:"avatar_url,omitempty"`
Location *string `json:"location,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
}


+ 2
- 2
github/orgs_members_test.go View File

@ -26,7 +26,7 @@ func TestOrganizationsService_ListMembers(t *testing.T) {
t.Errorf("Organizations.ListMembers returned error: %v", err)
}
want := []User{{ID: 1}}
want := []User{{ID: Int(1)}}
if !reflect.DeepEqual(members, want) {
t.Errorf("Organizations.ListMembers returned %+v, want %+v", members, want)
}
@ -51,7 +51,7 @@ func TestOrganizationsService_ListPublicMembers(t *testing.T) {
t.Errorf("Organizations.ListPublicMembers returned error: %v", err)
}
want := []User{{ID: 1}}
want := []User{{ID: Int(1)}}
if !reflect.DeepEqual(members, want) {
t.Errorf("Organizations.ListPublicMembers returned %+v, want %+v", members, want)
}


+ 7
- 7
github/orgs_teams.go View File

@ -10,13 +10,13 @@ import "fmt"
// Team represents a team within a GitHub organization. Teams are used to
// manage access to an organization's repositories.
type Team struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Slug string `json:"slug,omitempty"`
Permission string `json:"permission,omitempty"`
MembersCount int `json:"members_count,omitempty"`
ReposCount int `json:"repos_count,omitempty"`
ID *int `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
URL *string `json:"url,omitempty"`
Slug *string `json:"slug,omitempty"`
Permission *string `json:"permission,omitempty"`
MembersCount *int `json:"members_count,omitempty"`
ReposCount *int `json:"repos_count,omitempty"`
}
// ListTeams lists all of the teams for an organization.


+ 8
- 8
github/orgs_teams_test.go View File

@ -27,7 +27,7 @@ func TestOrganizationsService_ListTeams(t *testing.T) {
t.Errorf("Organizations.ListTeams returned error: %v", err)
}
want := []Team{{ID: 1}}
want := []Team{{ID: Int(1)}}
if !reflect.DeepEqual(teams, want) {
t.Errorf("Organizations.ListTeams returned %+v, want %+v", teams, want)
}
@ -52,7 +52,7 @@ func TestOrganizationsService_GetTeam(t *testing.T) {
t.Errorf("Organizations.GetTeam returned error: %v", err)
}
want := &Team{ID: 1, Name: "n", URL: "u", Slug: "s", Permission: "p"}
want := &Team{ID: Int(1), Name: String("n"), URL: String("u"), Slug: String("s"), Permission: String("p")}
if !reflect.DeepEqual(team, want) {
t.Errorf("Organizations.GetTeam returned %+v, want %+v", team, want)
}
@ -62,7 +62,7 @@ func TestOrganizationsService_CreateTeam(t *testing.T) {
setup()
defer teardown()
input := &Team{Name: "n"}
input := &Team{Name: String("n")}
mux.HandleFunc("/orgs/o/teams", func(w http.ResponseWriter, r *http.Request) {
v := new(Team)
@ -81,7 +81,7 @@ func TestOrganizationsService_CreateTeam(t *testing.T) {
t.Errorf("Organizations.CreateTeam returned error: %v", err)
}
want := &Team{ID: 1}
want := &Team{ID: Int(1)}
if !reflect.DeepEqual(team, want) {
t.Errorf("Organizations.CreateTeam returned %+v, want %+v", team, want)
}
@ -96,7 +96,7 @@ func TestOrganizationsService_EditTeam(t *testing.T) {
setup()
defer teardown()
input := &Team{Name: "n"}
input := &Team{Name: String("n")}
mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) {
v := new(Team)
@ -115,7 +115,7 @@ func TestOrganizationsService_EditTeam(t *testing.T) {
t.Errorf("Organizations.EditTeam returned error: %v", err)
}
want := &Team{ID: 1}
want := &Team{ID: Int(1)}
if !reflect.DeepEqual(team, want) {
t.Errorf("Organizations.EditTeam returned %+v, want %+v", team, want)
}
@ -149,7 +149,7 @@ func TestOrganizationsService_ListTeamMembers(t *testing.T) {
t.Errorf("Organizations.ListTeamMembers returned error: %v", err)
}
want := []User{{ID: 1}}
want := []User{{ID: Int(1)}}
if !reflect.DeepEqual(members, want) {
t.Errorf("Organizations.ListTeamMembers returned %+v, want %+v", members, want)
}
@ -310,7 +310,7 @@ func TestOrganizationsService_ListTeamRepos(t *testing.T) {
t.Errorf("Organizations.ListTeamRepos returned error: %v", err)
}
want := []Repository{{ID: 1}}
want := []Repository{{ID: Int(1)}}
if !reflect.DeepEqual(members, want) {
t.Errorf("Organizations.ListTeamRepos returned %+v, want %+v", members, want)
}


+ 5
- 5
github/orgs_test.go View File

@ -27,7 +27,7 @@ func TestOrganizationsService_List_authenticatedUser(t *testing.T) {
t.Errorf("Organizations.List returned error: %v", err)
}
want := []Organization{{ID: 1}, {ID: 2}}
want := []Organization{{ID: Int(1)}, {ID: Int(2)}}
if !reflect.DeepEqual(orgs, want) {
t.Errorf("Organizations.List returned %+v, want %+v", orgs, want)
}
@ -49,7 +49,7 @@ func TestOrganizationsService_List_specifiedUser(t *testing.T) {
t.Errorf("Organizations.List returned error: %v", err)
}
want := []Organization{{ID: 1}, {ID: 2}}
want := []Organization{{ID: Int(1)}, {ID: Int(2)}}
if !reflect.DeepEqual(orgs, want) {
t.Errorf("Organizations.List returned %+v, want %+v", orgs, want)
}
@ -74,7 +74,7 @@ func TestOrganizationsService_Get(t *testing.T) {
t.Errorf("Organizations.Get returned error: %v", err)
}
want := &Organization{ID: 1, Login: "l", URL: "u", AvatarURL: "a", Location: "l"}
want := &Organization{ID: Int(1), Login: String("l"), URL: String("u"), AvatarURL: String("a"), Location: String("l")}
if !reflect.DeepEqual(org, want) {
t.Errorf("Organizations.Get returned %+v, want %+v", org, want)
}
@ -89,7 +89,7 @@ func TestOrganizationsService_Edit(t *testing.T) {
setup()
defer teardown()
input := &Organization{Login: "l"}
input := &Organization{Login: String("l")}
mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) {
v := new(Organization)
@ -108,7 +108,7 @@ func TestOrganizationsService_Edit(t *testing.T) {
t.Errorf("Organizations.Edit returned error: %v", err)
}
want := &Organization{ID: 1}
want := &Organization{ID: Int(1)}
if !reflect.DeepEqual(org, want) {
t.Errorf("Organizations.Edit returned %+v, want %+v", org, want)
}


+ 11
- 11
github/pulls.go View File

@ -21,23 +21,23 @@ type PullRequestsService struct {
// PullRequest represents a GitHub pull request on a repository.
type PullRequest struct {
Number int `json:"number,omitempty"`
State string `json:"state,omitempty"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
Number *int `json:"number,omitempty"`
State *string `json:"state,omitempty"`
Title *string `json:"title,omitempty"`
Body *string `json:"body,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
ClosedAt *time.Time `json:"closed_at,omitempty"`
MergedAt *time.Time `json:"merged_at,omitempty"`
User *User `json:"user,omitempty"`
Merged bool `json:"merged,omitempty"`
Mergeable bool `json:"mergeable,omitempty"`
Merged *bool `json:"merged,omitempty"`
Mergeable *bool `json:"mergeable,omitempty"`
MergedBy *User `json:"merged_by,omitempty"`
Comments int `json:"comments,omitempty"`
Commits int `json:"commits,omitempty"`
Additions int `json:"additions,omitempty"`
Deletions int `json:"deletions,omitempty"`
ChangedFiles int `json:"changed_files,omitempty"`
Comments *int `json:"comments,omitempty"`
Commits *int `json:"commits,omitempty"`
Additions *int `json:"additions,omitempty"`
Deletions *int `json:"deletions,omitempty"`
ChangedFiles *int `json:"changed_files,omitempty"`
// TODO(willnorris): add head and base once we have a Commit struct defined somewhere
}


+ 5
- 5
github/pulls_comments.go View File

@ -13,11 +13,11 @@ import (
// PullRequestComment represents a comment left on a pull request.
type PullRequestComment struct {
ID int `json:"id,omitempty"`
Body string `json:"body,omitempty"`
Path string `json:"path,omitempty"`
Position int `json:"position,omitempty"`
CommitID string `json:"commit_id,omitempty"`
ID *int `json:"id,omitempty"`
Body *string `json:"body,omitempty"`
Path *string `json:"path,omitempty"`
Position *int `json:"position,omitempty"`
CommitID *string `json:"commit_id,omitempty"`
User *User `json:"user,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`


+ 7
- 7
github/pulls_comments_test.go View File

@ -37,7 +37,7 @@ func TestPullRequestsService_ListComments_allPulls(t *testing.T) {
t.Errorf("PullRequests.ListComments returned error: %v", err)
}
want := []PullRequestComment{{ID: 1}}
want := []PullRequestComment{{ID: Int(1)}}
if !reflect.DeepEqual(pulls, want) {
t.Errorf("PullRequests.ListComments returned %+v, want %+v", pulls, want)
}
@ -58,7 +58,7 @@ func TestPullRequestsService_ListComments_specificPull(t *testing.T) {
t.Errorf("PullRequests.ListComments returned error: %v", err)
}
want := []PullRequestComment{{ID: 1}}
want := []PullRequestComment{{ID: Int(1)}}
if !reflect.DeepEqual(pulls, want) {
t.Errorf("PullRequests.ListComments returned %+v, want %+v", pulls, want)
}
@ -84,7 +84,7 @@ func TestPullRequestsService_GetComment(t *testing.T) {
t.Errorf("PullRequests.GetComment returned error: %v", err)
}
want := &PullRequestComment{ID: 1}
want := &PullRequestComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("PullRequests.GetComment returned %+v, want %+v", comment, want)
}
@ -99,7 +99,7 @@ func TestPullRequestsService_CreateComment(t *testing.T) {
setup()
defer teardown()
input := &PullRequestComment{Body: "b"}
input := &PullRequestComment{Body: String("b")}
mux.HandleFunc("/repos/o/r/pulls/1/comments", func(w http.ResponseWriter, r *http.Request) {
v := new(PullRequestComment)
@ -119,7 +119,7 @@ func TestPullRequestsService_CreateComment(t *testing.T) {
t.Errorf("PullRequests.CreateComment returned error: %v", err)
}
want := &PullRequestComment{ID: 1}
want := &PullRequestComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("PullRequests.CreateComment returned %+v, want %+v", comment, want)
}
@ -134,7 +134,7 @@ func TestPullRequestsService_EditComment(t *testing.T) {
setup()
defer teardown()
input := &PullRequestComment{Body: "b"}
input := &PullRequestComment{Body: String("b")}
mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) {
v := new(PullRequestComment)
@ -154,7 +154,7 @@ func TestPullRequestsService_EditComment(t *testing.T) {
t.Errorf("PullRequests.EditComment returned error: %v", err)
}
want := &PullRequestComment{ID: 1}
want := &PullRequestComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("PullRequests.EditComment returned %+v, want %+v", comment, want)
}


+ 6
- 6
github/pulls_test.go View File

@ -34,7 +34,7 @@ func TestPullRequestsService_List(t *testing.T) {
t.Errorf("PullRequests.List returned error: %v", err)
}
want := []PullRequest{{Number: 1}}
want := []PullRequest{{Number: Int(1)}}
if !reflect.DeepEqual(pulls, want) {
t.Errorf("PullRequests.List returned %+v, want %+v", pulls, want)
}
@ -60,7 +60,7 @@ func TestPullRequestsService_Get(t *testing.T) {
t.Errorf("PullRequests.Get returned error: %v", err)
}
want := &PullRequest{Number: 1}
want := &PullRequest{Number: Int(1)}
if !reflect.DeepEqual(pull, want) {
t.Errorf("PullRequests.Get returned %+v, want %+v", pull, want)
}
@ -75,7 +75,7 @@ func TestPullRequestsService_Create(t *testing.T) {
setup()
defer teardown()
input := &PullRequest{Title: "t"}
input := &PullRequest{Title: String("t")}
mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) {
v := new(PullRequest)
@ -94,7 +94,7 @@ func TestPullRequestsService_Create(t *testing.T) {
t.Errorf("PullRequests.Create returned error: %v", err)
}
want := &PullRequest{Number: 1}
want := &PullRequest{Number: Int(1)}
if !reflect.DeepEqual(pull, want) {
t.Errorf("PullRequests.Create returned %+v, want %+v", pull, want)
}
@ -109,7 +109,7 @@ func TestPullRequestsService_Edit(t *testing.T) {
setup()
defer teardown()
input := &PullRequest{Title: "t"}
input := &PullRequest{Title: String("t")}
mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
v := new(PullRequest)
@ -128,7 +128,7 @@ func TestPullRequestsService_Edit(t *testing.T) {
t.Errorf("PullRequests.Edit returned error: %v", err)
}
want := &PullRequest{Number: 1}
want := &PullRequest{Number: Int(1)}
if !reflect.DeepEqual(pull, want) {
t.Errorf("PullRequests.Edit returned %+v, want %+v", pull, want)
}


+ 3
- 3
github/repos.go View File

@ -21,10 +21,10 @@ type RepositoriesService struct {
// Repository represents a GitHub repository.
type Repository struct {
ID int `json:"id,omitempty"`
ID *int `json:"id,omitempty"`
Owner *User `json:"owner,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
PushedAt *Timestamp `json:"pushed_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`


+ 1
- 1
github/repos_collaborators_test.go View File

@ -26,7 +26,7 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) {
t.Errorf("Repositories.ListCollaborators returned error: %v", err)
}
want := []User{{ID: 1}, {ID: 2}}
want := []User{{ID: Int(1)}, {ID: Int(2)}}
if !reflect.DeepEqual(users, want) {
t.Errorf("Repositories.ListCollaborators returned %+v, want %+v", users, want)
}


+ 9
- 9
github/repos_comments.go View File

@ -12,18 +12,18 @@ import (
// RepositoryComment represents a comment for a commit, file, or line in a repository.
type RepositoryComment struct {
HTMLURL string `json:"html_url,omitempty"`
URL string `json:"url,omitempty"`
ID int `json:"id,omitempty"`
CommitID string `json:"commit_id,omitempty"`
User User `json:"user,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
URL *string `json:"url,omitempty"`
ID *int `json:"id,omitempty"`
CommitID *string `json:"commit_id,omitempty"`
User *User `json:"user,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
// User-mutable fields
Body string `json:"body"`
Path string `json:"path,omitempty"`
Position int `json:"position,omitempty"`
Body *string `json:"body"`
Path *string `json:"path,omitempty"`
Position *int `json:"position,omitempty"`
}
// ListComments lists all the comments for the repository.
@ -88,7 +88,7 @@ func (s *RepositoriesService) GetComment(owner, repo string, id int) (*Repositor
// GitHub API docs: http://developer.github.com/v3/repos/comments/#update-a-commit-comment
func (s *RepositoriesService) UpdateComment(owner, repo string, id int, body string) (*RepositoryComment, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/comments/%v", owner, repo, id)
comment := RepositoryComment{Body: body}
comment := RepositoryComment{Body: String(body)}
req, err := s.client.NewRequest("PATCH", u, &comment)
if err != nil {
return nil, nil, err


+ 8
- 8
github/repos_comments_test.go View File

@ -27,7 +27,7 @@ func TestRepositoriesService_ListComments(t *testing.T) {
t.Errorf("Repositories.ListComments returned error: %v", err)
}
want := []RepositoryComment{{ID: 1}, {ID: 2}}
want := []RepositoryComment{{ID: Int(1)}, {ID: Int(2)}}
if !reflect.DeepEqual(comments, want) {
t.Errorf("Repositories.ListComments returned %+v, want %+v", comments, want)
}
@ -47,7 +47,7 @@ func TestRepositoriesService_ListCommitComments(t *testing.T) {
t.Errorf("Repositories.ListCommitComments returned error: %v", err)
}
want := []RepositoryComment{{ID: 1}, {ID: 2}}
want := []RepositoryComment{{ID: Int(1)}, {ID: Int(2)}}
if !reflect.DeepEqual(comments, want) {
t.Errorf("Repositories.ListCommitComments returned %+v, want %+v", comments, want)
}
@ -57,7 +57,7 @@ func TestRepositoriesService_CreateComment(t *testing.T) {
setup()
defer teardown()
input := &RepositoryComment{Body: "asdf"}
input := &RepositoryComment{Body: String("b")}
mux.HandleFunc("/repos/o/r/commits/s/comments", func(w http.ResponseWriter, r *http.Request) {
v := new(RepositoryComment)
@ -76,7 +76,7 @@ func TestRepositoriesService_CreateComment(t *testing.T) {
t.Errorf("Repositories.CreateComment returned error: %v", err)
}
want := &RepositoryComment{ID: 1}
want := &RepositoryComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("Repositories.CreateComment returned %+v, want %+v", comment, want)
}
@ -96,7 +96,7 @@ func TestRepositoriesService_GetComment(t *testing.T) {
t.Errorf("Repositories.GetComment returned error: %v", err)
}
want := &RepositoryComment{ID: 1}
want := &RepositoryComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("Repositories.GetComment returned %+v, want %+v", comment, want)
}
@ -106,7 +106,7 @@ func TestRepositoriesService_UpdateComment(t *testing.T) {
setup()
defer teardown()
input := &RepositoryComment{Body: "asdf"}
input := &RepositoryComment{Body: String("b")}
mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) {
v := new(RepositoryComment)
@ -120,12 +120,12 @@ func TestRepositoriesService_UpdateComment(t *testing.T) {
fmt.Fprint(w, `{"id":1}`)
})
comment, _, err := client.Repositories.UpdateComment("o", "r", 1, "asdf")
comment, _, err := client.Repositories.UpdateComment("o", "r", 1, "b")
if err != nil {
t.Errorf("Repositories.UpdateComment returned error: %v", err)
}
want := &RepositoryComment{ID: 1}
want := &RepositoryComment{ID: Int(1)}
if !reflect.DeepEqual(comment, want) {
t.Errorf("Repositories.UpdateComment returned %+v, want %+v", comment, want)
}


+ 2
- 2
github/repos_forks_test.go View File

@ -28,7 +28,7 @@ func TestRepositoriesService_ListForks(t *testing.T) {
t.Errorf("Repositories.ListForks returned error: %v", err)
}
want := []Repository{{ID: 1}, {ID: 2}}
want := []Repository{{ID: Int(1)}, {ID: Int(2)}}
if !reflect.DeepEqual(repos, want) {
t.Errorf("Repositories.ListForks returned %+v, want %+v", repos, want)
}
@ -55,7 +55,7 @@ func TestRepositoriesService_CreateFork(t *testing.T) {
t.Errorf("Repositories.CreateFork returned error: %v", err)
}
want := &Repository{ID: 1}
want := &Repository{ID: Int(1)}
if !reflect.DeepEqual(repo, want) {
t.Errorf("Repositories.CreateFork returned %+v, want %+v", repo, want)
}


+ 22
- 22
github/repos_hooks.go View File

@ -20,50 +20,50 @@ import (
//
// GitHub API docs: https://help.github.com/articles/post-receive-hooks
type WebHookPayload struct {
After string `json:"after,omitempty"`
Before string `json:"before,omitempty"`
After *string `json:"after,omitempty"`
Before *string `json:"before,omitempty"`
Commits []WebHookCommit `json:"commits,omitempty"`
Compare string `json:"compare,omitempty"`
Created bool `json:"created,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Forced bool `json:"forced,omitempty"`
Compare *string `json:"compare,omitempty"`
Created *bool `json:"created,omitempty"`
Deleted *bool `json:"deleted,omitempty"`
Forced *bool `json:"forced,omitempty"`
HeadCommit *WebHookCommit `json:"head_commit,omitempty"`
Pusher *User `json:"pusher,omitempty"`
Ref string `json:"ref,omitempty"`
Ref *string `json:"ref,omitempty"`
Repo *Repository `json:"repository,omitempty"`
}
// WebHookCommit represents the commit variant we receive from GitHub in a
// WebHookPayload.
type WebHookCommit struct {
Added []string `json:"added,omitempty"`
Author WebHookAuthor `json:"author,omitempty"`
Committer WebHookAuthor `json:"committer,omitempty"`
Distinct bool `json:"distinct,omitempty"`
ID string `json:"id,omitempty"`
Message string `json:"message,omitempty"`
Modified []string `json:"modified,omitempty"`
Removed []string `json:"removed,omitempty"`
Timestamp *time.Time `json:"timestamp,omitempty"`
Added []string `json:"added,omitempty"`
Author *WebHookAuthor `json:"author,omitempty"`
Committer *WebHookAuthor `json:"committer,omitempty"`
Distinct *bool `json:"distinct,omitempty"`
ID *string `json:"id,omitempty"`
Message *string `json:"message,omitempty"`
Modified []string `json:"modified,omitempty"`
Removed []string `json:"removed,omitempty"`
Timestamp *time.Time `json:"timestamp,omitempty"`
}
// WebHookAuthor represents the author or committer of a commit, as specified
// in a WebHookCommit. The commit author may not correspond to a GitHub User.
type WebHookAuthor struct {
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
Username string `json:"username,omitempty"`
Email *string `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
Username *string `json:"username,omitempty"`
}
// Hook represents a GitHub (web and service) hook for a repository.
type Hook struct {
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
Name string `json:"name,omitempty"`
Name *string `json:"name,omitempty"`
Events []string `json:"events,omitempty"`
Active bool `json:"active,omitempty"`
Active *bool `json:"active,omitempty"`
Config map[string]interface{} `json:"config,omitempty"`
ID int `json:"id,omitempty"`
ID *int `json:"id,omitempty"`
}
// CreateHook creates a Hook for the specified repository.


+ 6
- 6
github/repos_hooks_test.go View File

@ -17,7 +17,7 @@ func TestRepositoriesService_CreateHook(t *testing.T) {
setup()
defer teardown()
input := &Hook{Name: "t"}
input := &Hook{Name: String("t")}
mux.HandleFunc("/repos/o/r/hooks", func(w http.ResponseWriter, r *http.Request) {
v := new(Hook)
@ -36,7 +36,7 @@ func TestRepositoriesService_CreateHook(t *testing.T) {
t.Errorf("Repositories.CreateHook returned error: %v", err)
}
want := &Hook{ID: 1}
want := &Hook{ID: Int(1)}
if !reflect.DeepEqual(hook, want) {
t.Errorf("Repositories.CreateHook returned %+v, want %+v", hook, want)
}
@ -59,7 +59,7 @@ func TestRepositoriesService_ListHooks(t *testing.T) {
t.Errorf("Repositories.ListHooks returned error: %v", err)
}
want := []Hook{{ID: 1}, {ID: 2}}
want := []Hook{{ID: Int(1)}, {ID: Int(2)}}
if !reflect.DeepEqual(hooks, want) {
t.Errorf("Repositories.ListHooks returned %+v, want %+v", hooks, want)
}
@ -79,7 +79,7 @@ func TestRepositoriesService_GetHook(t *testing.T) {
t.Errorf("Repositories.GetHook returned error: %v", err)
}
want := &Hook{ID: 1}
want := &Hook{ID: Int(1)}
if !reflect.DeepEqual(hook, want) {
t.Errorf("Repositories.GetHook returned %+v, want %+v", hook, want)
}
@ -89,7 +89,7 @@ func TestRepositoriesService_EditHook(t *testing.T) {
setup()
defer teardown()
input := &Hook{Name: "t"}
input := &Hook{Name: String("t")}
mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) {
v := new(Hook)
@ -108,7 +108,7 @@ func TestRepositoriesService_EditHook(t *testing.T) {
t.Errorf("Repositories.EditHook returned error: %v", err)
}
want := &Hook{ID: 1}
want := &Hook{ID: Int(1)}
if !reflect.DeepEqual(hook, want) {
t.Errorf("Repositories.EditHook returned %+v, want %+v", hook, want)
}


+ 4
- 4
github/repos_statuses.go View File

@ -12,18 +12,18 @@ import (
// RepoStatus represents the status of a repository at a particular reference.
type RepoStatus struct {
ID int `json:"id,omitempty"`
ID *int `json:"id,omitempty"`
// State is the current state of the repository. Possible values are:
// pending, success, error, or failure.
State string `json:"state,omitempty"`
State *string `json:"state,omitempty"`
// TargetURL is the URL of the page representing this status. It will be
// linked from the GitHub UI to allow users to see the source of the status.
TargetURL string `json:"target_url,omitempty"`
TargetURL *string `json:"target_url,omitempty"`
// Description is a short high level summary of the status.
Description string `json:"description,omitempty"`
Description *string `json:"description,omitempty"`
Creator *User `json:"creator,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`


+ 3
- 3
github/repos_statuses_test.go View File

@ -27,7 +27,7 @@ func TestRepositoriesService_ListStatuses(t *testing.T) {
t.Errorf("Repositories.ListStatuses returned error: %v", err)
}
want := []RepoStatus{{ID: 1}}
want := []RepoStatus{{ID: Int(1)}}
if !reflect.DeepEqual(statuses, want) {
t.Errorf("Repositories.ListStatuses returned %+v, want %+v", statuses, want)
}
@ -42,7 +42,7 @@ func TestRepositoriesService_CreateStatus(t *testing.T) {
setup()
defer teardown()
input := &RepoStatus{State: "s", TargetURL: "t", Description: "d"}
input := &RepoStatus{State: String("s"), TargetURL: String("t"), Description: String("d")}
mux.HandleFunc("/repos/o/r/statuses/r", func(w http.ResponseWriter, r *http.Request) {
v := new(RepoStatus)
@ -60,7 +60,7 @@ func TestRepositoriesService_CreateStatus(t *testing.T) {
t.Errorf("Repositories.CreateStatus returned error: %v", err)
}
want := &RepoStatus{ID: 1}
want := &RepoStatus{ID: Int(1)}
if !reflect.DeepEqual(status, want) {
t.Errorf("Repositories.CreateStatus returned %+v, want %+v", status, want)
}


+ 10
- 10
github/repos_test.go View File

@ -27,7 +27,7 @@ func TestRepositoriesService_List_authenticatedUser(t *testing.T) {
t.Errorf("Repositories.List returned error: %v", err)
}
want := []Repository{{ID: 1}, {ID: 2}}
want := []Repository{{ID: Int(1)}, {ID: Int(2)}}
if !reflect.DeepEqual(repos, want) {
t.Errorf("Repositories.List returned %+v, want %+v", repos, want)
}
@ -55,7 +55,7 @@ func TestRepositoriesService_List_specifiedUser(t *testing.T) {
t.Errorf("Repositories.List returned error: %v", err)
}
want := []Repository{{ID: 1}}
want := []Repository{{ID: Int(1)}}
if !reflect.DeepEqual(repos, want) {
t.Errorf("Repositories.List returned %+v, want %+v", repos, want)
}
@ -85,7 +85,7 @@ func TestRepositoriesService_ListByOrg(t *testing.T) {
t.Errorf("Repositories.ListByOrg returned error: %v", err)
}
want := []Repository{{ID: 1}}
want := []Repository{{ID: Int(1)}}
if !reflect.DeepEqual(repos, want) {
t.Errorf("Repositories.ListByOrg returned %+v, want %+v", repos, want)
}
@ -112,7 +112,7 @@ func TestRepositoriesService_ListAll(t *testing.T) {
t.Errorf("Repositories.ListAll returned error: %v", err)
}
want := []Repository{{ID: 1}}
want := []Repository{{ID: Int(1)}}
if !reflect.DeepEqual(repos, want) {
t.Errorf("Repositories.ListAll returned %+v, want %+v", repos, want)
}
@ -122,7 +122,7 @@ func TestRepositoriesService_Create_user(t *testing.T) {
setup()
defer teardown()
input := &Repository{Name: "n"}
input := &Repository{Name: String("n")}
mux.HandleFunc("/user/repos", func(w http.ResponseWriter, r *http.Request) {
v := new(Repository)
@ -141,7 +141,7 @@ func TestRepositoriesService_Create_user(t *testing.T) {
t.Errorf("Repositories.Create returned error: %v", err)
}
want := &Repository{ID: 1}
want := &Repository{ID: Int(1)}
if !reflect.DeepEqual(repo, want) {
t.Errorf("Repositories.Create returned %+v, want %+v", repo, want)
}
@ -151,7 +151,7 @@ func TestRepositoriesService_Create_org(t *testing.T) {
setup()
defer teardown()
input := &Repository{Name: "n"}
input := &Repository{Name: String("n")}
mux.HandleFunc("/orgs/o/repos", func(w http.ResponseWriter, r *http.Request) {
v := new(Repository)
@ -170,7 +170,7 @@ func TestRepositoriesService_Create_org(t *testing.T) {
t.Errorf("Repositories.Create returned error: %v", err)
}
want := &Repository{ID: 1}
want := &Repository{ID: Int(1)}
if !reflect.DeepEqual(repo, want) {
t.Errorf("Repositories.Create returned %+v, want %+v", repo, want)
}
@ -195,7 +195,7 @@ func TestRepositoriesService_Get(t *testing.T) {
t.Errorf("Repositories.Get returned error: %v", err)
}
want := &Repository{ID: 1, Name: "n", Description: "d", Owner: &User{Login: "l"}}
want := &Repository{ID: Int(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}}
if !reflect.DeepEqual(repo, want) {
t.Errorf("Repositories.Get returned %+v, want %+v", repo, want)
}
@ -224,7 +224,7 @@ func TestRepositoriesService_Edit(t *testing.T) {
t.Errorf("Repositories.Edit returned error: %v", err)
}
want := &Repository{ID: 1}
want := &Repository{ID: Int(1)}
if !reflect.DeepEqual(repo, want) {
t.Errorf("Repositories.Edit returned %+v, want %+v", repo, want)
}


+ 8
- 8
github/search.go View File

@ -44,7 +44,7 @@ type SearchOptions struct {
// RepositoriesSearchResult represents the result of a repositories search.
type RepositoriesSearchResult struct {
Total int `json:"total_count,omitempty"`
Total *int `json:"total_count,omitempty"`
Repositories []Repository `json:"items,omitempty"`
}
@ -59,7 +59,7 @@ func (s *SearchService) Repositories(query string, opt *SearchOptions) (*Reposit
// IssuesSearchResult represents the result of an issues search.
type IssuesSearchResult struct {
Total int `json:"total_count,omitempty"`
Total *int `json:"total_count,omitempty"`
Issues []Issue `json:"items,omitempty"`
}
@ -74,7 +74,7 @@ func (s *SearchService) Issues(query string, opt *SearchOptions) (*IssuesSearchR
// UsersSearchResult represents the result of an issues search.
type UsersSearchResult struct {
Total int `json:"total_count,omitempty"`
Total *int `json:"total_count,omitempty"`
Users []User `json:"items,omitempty"`
}
@ -89,16 +89,16 @@ func (s *SearchService) Users(query string, opt *SearchOptions) (*UsersSearchRes
// CodeSearchResult represents the result of an code search.
type CodeSearchResult struct {
Total int `json:"total_count,omitempty"`
Total *int `json:"total_count,omitempty"`
CodeResults []CodeResult `json:"items,omitempty"`
}
// CodeResult represents a single search result.
type CodeResult struct {
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
SHA string `json:"sha,omitempty"`
HTMLURL string `json:"html_url,omitempty"`
Name *string `json:"name,omitempty"`
Path *string `json:"path,omitempty"`
SHA *string `json:"sha,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
Repository *Repository `json:"repository,omitempty"`
}


+ 8
- 8
github/search_test.go View File

@ -33,8 +33,8 @@ func TestSearchService_Repositories(t *testing.T) {
}
want := &RepositoriesSearchResult{
Total: 4,
Repositories: []Repository{{ID: 1}, {ID: 2}},
Total: Int(4),
Repositories: []Repository{{ID: Int(1)}, {ID: Int(2)}},
}
if !reflect.DeepEqual(result, want) {
t.Errorf("Search.Repositories returned %+v, want %+v", result, want)
@ -66,8 +66,8 @@ func TestSearchService_Issues(t *testing.T) {
}
want := &IssuesSearchResult{
Total: 4,
Issues: []Issue{{Number: 1}, {Number: 2}},
Total: Int(4),
Issues: []Issue{{Number: Int(1)}, {Number: Int(2)}},
}
if !reflect.DeepEqual(result, want) {
t.Errorf("Search.Issues returned %+v, want %+v", result, want)
@ -99,8 +99,8 @@ func TestSearchService_Users(t *testing.T) {
}
want := &UsersSearchResult{
Total: 4,
Users: []User{{ID: 1}, {ID: 2}},
Total: Int(4),
Users: []User{{ID: Int(1)}, {ID: Int(2)}},
}
if !reflect.DeepEqual(result, want) {
t.Errorf("Search.Users returned %+v, want %+v", result, want)
@ -132,8 +132,8 @@ func TestSearchService_Code(t *testing.T) {
}
want := &CodeSearchResult{
Total: 4,
CodeResults: []CodeResult{{Name: "1"}, {Name: "2"}},
Total: Int(4),
CodeResults: []CodeResult{{Name: String("1")}, {Name: String("2")}},
}
if !reflect.DeepEqual(result, want) {
t.Errorf("Search.Code returned %+v, want %+v", result, want)


+ 14
- 14
github/users.go View File

@ -22,20 +22,20 @@ type UsersService struct {
// User represents a GitHub user.
type User struct {
Login string `json:"login,omitempty"`
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
GravatarID string `json:"gravatar_id,omitempty"`
Name string `json:"name,omitempty"`
Company string `json:"company,omitempty"`
Blog string `json:"blog,omitempty"`
Location string `json:"location,omitempty"`
Email string `json:"email,omitempty"`
Hireable bool `json:"hireable,omitempty"`
PublicRepos int `json:"public_repos,omitempty"`
Followers int `json:"followers,omitempty"`
Following int `json:"following,omitempty"`
Login *string `json:"login,omitempty"`
ID *int `json:"id,omitempty"`
URL *string `json:"url,omitempty"`
AvatarURL *string `json:"avatar_url,omitempty"`
GravatarID *string `json:"gravatar_id,omitempty"`
Name *string `json:"name,omitempty"`
Company *string `json:"company,omitempty"`
Blog *string `json:"blog,omitempty"`
Location *string `json:"location,omitempty"`
Email *string `json:"email,omitempty"`
Hireable *bool `json:"hireable,omitempty"`
PublicRepos *int `json:"public_repos,omitempty"`
Followers *int `json:"followers,omitempty"`
Following *int `json:"following,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
}


+ 5
- 5
github/users_test.go View File

@ -27,7 +27,7 @@ func TestUsersService_Get_authenticatedUser(t *testing.T) {
t.Errorf("Users.Get returned error: %v", err)
}
want := &User{ID: 1}
want := &User{ID: Int(1)}
if !reflect.DeepEqual(user, want) {
t.Errorf("Users.Get returned %+v, want %+v", user, want)
}
@ -47,7 +47,7 @@ func TestUsersService_Get_specifiedUser(t *testing.T) {
t.Errorf("Users.Get returned error: %v", err)
}
want := &User{ID: 1}
want := &User{ID: Int(1)}
if !reflect.DeepEqual(user, want) {
t.Errorf("Users.Get returned %+v, want %+v", user, want)
}
@ -62,7 +62,7 @@ func TestUsersService_Edit(t *testing.T) {
setup()
defer teardown()
input := &User{Name: "n"}
input := &User{Name: String("n")}
mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) {
v := new(User)
@ -81,7 +81,7 @@ func TestUsersService_Edit(t *testing.T) {
t.Errorf("Users.Edit returned error: %v", err)
}
want := &User{ID: 1}
want := &User{ID: Int(1)}
if !reflect.DeepEqual(user, want) {
t.Errorf("Users.Edit returned %+v, want %+v", user, want)
}
@ -103,7 +103,7 @@ func TestUsersService_ListAll(t *testing.T) {
t.Errorf("Users.Get returned error: %v", err)
}
want := []User{{ID: 2}}
want := []User{{ID: Int(2)}}
if !reflect.DeepEqual(users, want) {
t.Errorf("Users.ListAll returned %+v, want %+v", users, want)
}


Loading…
Cancel
Save