Skip to content

Commit

Permalink
Fix GitHub ListPullRequestReviews (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi authored Sep 13, 2023
1 parent 5004344 commit 2c007f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions vcsclient/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func (client *GitHubClient) ListPullRequestReviewComments(ctx context.Context, o
if err != nil {
return nil, err
}
commentsList, _, err := ghClient.PullRequests.ListReviews(ctx, owner, repository, pullRequestID, nil)
commentsList, _, err := ghClient.PullRequests.ListComments(ctx, owner, repository, pullRequestID, nil)
if err != nil {
return []CommentInfo{}, err
}
Expand All @@ -482,7 +482,7 @@ func (client *GitHubClient) ListPullRequestReviewComments(ctx context.Context, o
commentsInfoList = append(commentsInfoList, CommentInfo{
ID: comment.GetID(),
Content: comment.GetBody(),
Created: comment.GetSubmittedAt(),
Created: comment.GetCreatedAt(),
})
}
return commentsInfoList, nil
Expand Down
4 changes: 3 additions & 1 deletion vcsclient/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,16 @@ func TestGitHubClient_ListPullRequestReviewComments(t *testing.T) {
ctx := context.Background()
id := int64(1)
body := "test"
client, cleanUp := createServerAndClient(t, vcsutils.GitHub, false, []*github.PullRequestReview{{ID: &id, Body: &body}}, "/repos/jfrog/repo-1/pulls/1/reviews", createGitHubHandler)
created := time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)
client, cleanUp := createServerAndClient(t, vcsutils.GitHub, false, []*github.PullRequestComment{{ID: &id, Body: &body, CreatedAt: &created}}, "/repos/jfrog/repo-1/pulls/1/comments", createGitHubHandler)
defer cleanUp()

commentInfo, err := client.ListPullRequestReviewComments(ctx, owner, repo1, 1)
assert.NoError(t, err)
assert.Len(t, commentInfo, 1)
assert.Equal(t, id, commentInfo[0].ID)
assert.Equal(t, body, commentInfo[0].Content)
assert.Equal(t, created, commentInfo[0].Created)

commentInfo, err = createBadGitHubClient(t).ListPullRequestReviewComments(ctx, owner, repo1, 1)
assert.Nil(t, commentInfo)
Expand Down

0 comments on commit 2c007f4

Please sign in to comment.