Browse Source

Add review_comment{s,}_url fields to PullRequest

Generalise and add to PullRequestsService URL test

Fixes #453.
Closes #454.

Change-Id: Iaee7d8498d1d6a0813bbba14261e4393f77c9d1f
Bradley Falzon 9 years ago
committed by Glenn Lewis
parent
commit
6afedaae20
2 changed files with 51 additions and 32 deletions
  1. +29
    -27
      github/pulls.go
  2. +22
    -5
      github/pulls_test.go

+ 29
- 27
github/pulls.go View File

@ -18,33 +18,35 @@ type PullRequestsService service
// PullRequest represents a GitHub pull request on a repository. // PullRequest represents a GitHub pull request on a repository.
type PullRequest struct { type PullRequest struct {
ID *int `json:"id,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"`
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"`
URL *string `json:"url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
IssueURL *string `json:"issue_url,omitempty"`
StatusesURL *string `json:"statuses_url,omitempty"`
DiffURL *string `json:"diff_url,omitempty"`
PatchURL *string `json:"patch_url,omitempty"`
Assignee *User `json:"assignee,omitempty"`
Assignees []*User `json:"assignees,omitempty"`
Milestone *Milestone `json:"milestone,omitempty"`
ID *int `json:"id,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"`
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"`
URL *string `json:"url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
IssueURL *string `json:"issue_url,omitempty"`
StatusesURL *string `json:"statuses_url,omitempty"`
DiffURL *string `json:"diff_url,omitempty"`
PatchURL *string `json:"patch_url,omitempty"`
ReviewCommentsURL *string `json:"review_comments_url,omitempty"`
ReviewCommentURL *string `json:"review_comment_url,omitempty"`
Assignee *User `json:"assignee,omitempty"`
Assignees []*User `json:"assignees,omitempty"`
Milestone *Milestone `json:"milestone,omitempty"`
Head *PullRequestBranch `json:"head,omitempty"` Head *PullRequestBranch `json:"head,omitempty"`
Base *PullRequestBranch `json:"base,omitempty"` Base *PullRequestBranch `json:"base,omitempty"`


+ 22
- 5
github/pulls_test.go View File

@ -97,15 +97,21 @@ func TestPullRequestsService_Get_headAndBase(t *testing.T) {
} }
} }
func TestPullRequestService_Get_DiffURLAndPatchURL(t *testing.T) {
func TestPullRequestsService_Get_urlFields(t *testing.T) {
setup() setup()
defer teardown() defer teardown()
mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET") testMethod(t, r, "GET")
fmt.Fprint(w, `{"number":1,
"diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff",
"patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch"}`)
fmt.Fprint(w, `{"number":1,
"url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347",
"html_url": "https://github.com/octocat/Hello-World/pull/1347",
"issue_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347",
"statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff",
"patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch",
"review_comments_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments",
"review_comment_url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"}`)
}) })
pull, _, err := client.PullRequests.Get("o", "r", 1) pull, _, err := client.PullRequests.Get("o", "r", 1)
@ -113,7 +119,18 @@ func TestPullRequestService_Get_DiffURLAndPatchURL(t *testing.T) {
t.Errorf("PullRequests.Get returned error: %v", err) t.Errorf("PullRequests.Get returned error: %v", err)
} }
want := &PullRequest{Number: Int(1), DiffURL: String("https://github.com/octocat/Hello-World/pull/1347.diff"), PatchURL: String("https://github.com/octocat/Hello-World/pull/1347.patch")}
want := &PullRequest{
Number: Int(1),
URL: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347"),
HTMLURL: String("https://github.com/octocat/Hello-World/pull/1347"),
IssueURL: String("https://api.github.com/repos/octocat/Hello-World/issues/1347"),
StatusesURL: String("https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"),
DiffURL: String("https://github.com/octocat/Hello-World/pull/1347.diff"),
PatchURL: String("https://github.com/octocat/Hello-World/pull/1347.patch"),
ReviewCommentsURL: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"),
ReviewCommentURL: String("https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"),
}
if !reflect.DeepEqual(pull, want) { if !reflect.DeepEqual(pull, want) {
t.Errorf("PullRequests.Get returned %+v, want %+v", pull, want) t.Errorf("PullRequests.Get returned %+v, want %+v", pull, want)
} }


Loading…
Cancel
Save