diff --git a/github/issues_timeline.go b/github/issues_timeline.go index ffd9b6fecfc..903f5b89c34 100644 --- a/github/issues_timeline.go +++ b/github/issues_timeline.go @@ -97,6 +97,14 @@ type Timeline struct { // reviewed // The pull request was reviewed. // + // review_requested + // The actor requested a review from a user or team. + // Reviewer and Requester/RequestedTeam will be populated. + // + // review_request_removed + // The actor removed a review request from a user or team. + // Reviewer and Requester/RequestedTeam will be populated. + // // subscribed // The actor subscribed to receive notifications for an issue. // diff --git a/github/issues_timeline_test.go b/github/issues_timeline_test.go index 1e88f500d99..ed7649489e2 100644 --- a/github/issues_timeline_test.go +++ b/github/issues_timeline_test.go @@ -255,3 +255,91 @@ func TestTimeline_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestTimeline_ReviewRequests(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/repos/example-org/example-repo/issues/3/timeline", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `[{ + "id": 1234567890, + "url": "http://example.com/timeline/1", + "actor": { + "login": "actor-user", + "id": 1 + }, + "event": "review_requested", + "created_at": "2006-01-02T15:04:05Z", + "requested_reviewer": { + "login": "reviewer-user", + "id": 2 + }, + "review_requester": { + "login": "requester-user", + "id": 1 + } + }, + { + "id": 1234567891, + "url": "http://example.com/timeline/2", + "actor": { + "login": "actor-user", + "id": 1 + }, + "event": "review_request_removed", + "created_at": "2006-01-02T15:04:05Z", + "requested_reviewer": { + "login": "reviewer-user", + "id": 2 + } + }]`) + }) + + ctx := context.Background() + events, _, err := client.Issues.ListIssueTimeline(ctx, "example-org", "example-repo", 3, nil) + if err != nil { + t.Errorf("Issues.ListIssueTimeline returned error: %v", err) + } + + want := []*Timeline{ + { + ID: Ptr(int64(1234567890)), + URL: Ptr("http://example.com/timeline/1"), + Actor: &User{ + Login: Ptr("actor-user"), + ID: Ptr(int64(1)), + }, + Event: Ptr("review_requested"), + CreatedAt: &Timestamp{referenceTime}, + Reviewer: &User{ + Login: Ptr("reviewer-user"), + ID: Ptr(int64(2)), + }, + Requester: &User{ + Login: Ptr("requester-user"), + ID: Ptr(int64(1)), + }, + }, + { + ID: Ptr(int64(1234567891)), + URL: Ptr("http://example.com/timeline/2"), + Actor: &User{ + Login: Ptr("actor-user"), + ID: Ptr(int64(1)), + }, + Event: Ptr("review_request_removed"), + CreatedAt: &Timestamp{referenceTime}, + Reviewer: &User{ + Login: Ptr("reviewer-user"), + ID: Ptr(int64(2)), + }, + }, + } + + if !cmp.Equal(events, want) { + t.Errorf("Issues.ListIssueTimeline review request events = %+v, want %+v", events, want) + diff := cmp.Diff(events, want) + t.Errorf("Difference: %s", diff) + } +}