fix(github): clarify PostReview doc comment, rename test field to 'want'
Address review feedback from round-3 sonnet review: - PostReview doc comment now accurately describes vcs.ReviewEvent → GitHub wire-format string cast and notes nil-Comments omitempty behavior. - Rename 'expected' field to 'want' in TestTranslateGitHubReviewState to match the project's established naming convention.
This commit is contained in:
+8
-2
@@ -66,9 +66,15 @@ func translateGitHubReviewState(state string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PostReview submits a review on a pull request.
|
// PostReview submits a review on a pull request.
|
||||||
// The ReviewRequest.Event values (APPROVE, REQUEST_CHANGES, COMMENT) are sent
|
//
|
||||||
// directly — they match GitHub's canonical event strings.
|
// The vcs.ReviewEvent constants (ReviewEventApprove, ReviewEventRequestChanges,
|
||||||
|
// ReviewEventComment) have string values that match GitHub's wire-format event
|
||||||
|
// strings (APPROVE, REQUEST_CHANGES, COMMENT), so Event is cast directly to
|
||||||
|
// string without translation.
|
||||||
|
//
|
||||||
// ReviewComment.Position maps directly to the GitHub API position field.
|
// ReviewComment.Position maps directly to the GitHub API position field.
|
||||||
|
// When req.Comments is empty, the payload omits the comments field entirely
|
||||||
|
// (via the omitempty tag on postReviewRequest.Comments).
|
||||||
func (c *Client) PostReview(ctx context.Context, owner, repo string, number int, req vcs.ReviewRequest) (*vcs.Review, error) {
|
func (c *Client) PostReview(ctx context.Context, owner, repo string, number int, req vcs.ReviewRequest) (*vcs.Review, error) {
|
||||||
reqURL := fmt.Sprintf("%s/repos/%s/%s/pulls/%d/reviews",
|
reqURL := fmt.Sprintf("%s/repos/%s/%s/pulls/%d/reviews",
|
||||||
c.baseURL, url.PathEscape(owner), url.PathEscape(repo), number)
|
c.baseURL, url.PathEscape(owner), url.PathEscape(repo), number)
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ func TestDismissReview_401(t *testing.T) {
|
|||||||
func TestTranslateGitHubReviewState(t *testing.T) {
|
func TestTranslateGitHubReviewState(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input string
|
input string
|
||||||
expected string
|
want string
|
||||||
}{
|
}{
|
||||||
{"APPROVED", "APPROVED"},
|
{"APPROVED", "APPROVED"},
|
||||||
{"CHANGES_REQUESTED", "REQUEST_CHANGES"},
|
{"CHANGES_REQUESTED", "REQUEST_CHANGES"},
|
||||||
@@ -374,8 +374,8 @@ func TestTranslateGitHubReviewState(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
got := translateGitHubReviewState(tt.input)
|
got := translateGitHubReviewState(tt.input)
|
||||||
if got != tt.expected {
|
if got != tt.want {
|
||||||
t.Errorf("translateGitHubReviewState(%q) = %q, want %q", tt.input, got, tt.expected)
|
t.Errorf("translateGitHubReviewState(%q) = %q, want %q", tt.input, got, tt.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user