fix(#130): cleanup and test improvements
PR Ready Gate / clear-labels (pull_request) Successful in 2s
CI / test (pull_request) Successful in 17s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 39s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m3s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m7s
PR Ready Gate / clear-labels (pull_request) Successful in 2s
CI / test (pull_request) Successful in 17s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 39s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m3s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m7s
- Fix extra blank lines between GetPullRequest and GetPullRequestFiles - Add TestPostReview_CommitIDFromRequest to verify CommitID passes through
This commit is contained in:
@@ -542,3 +542,41 @@ func TestDoRequestWithBody_RejectsHTTP(t *testing.T) {
|
||||
t.Fatal("expected error for HTTP request")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPostReview_CommitIDFromRequest(t *testing.T) {
|
||||
const wantCommitID = "abc123def456"
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var payload postReviewRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
|
||||
t.Errorf("decode body: %v", err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if payload.CommitID != wantCommitID {
|
||||
t.Errorf("commit_id = %q, want %q", payload.CommitID, wantCommitID)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(reviewResponse{
|
||||
ID: 1,
|
||||
Body: payload.Body,
|
||||
State: "COMMENTED",
|
||||
CommitID: payload.CommitID,
|
||||
User: struct{ Login string `json:"login"` }{Login: "rodin"},
|
||||
})
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
c := NewClient("tok", srv.URL, AllowInsecureHTTPForTest())
|
||||
review, err := c.PostReview(context.Background(), "owner", "repo", 1, vcs.ReviewRequest{
|
||||
Body: "looks good",
|
||||
Event: vcs.ReviewEventApprove,
|
||||
CommitID: wantCommitID,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("PostReview: %v", err)
|
||||
}
|
||||
if review.CommitID != wantCommitID {
|
||||
t.Errorf("review.CommitID = %q, want %q", review.CommitID, wantCommitID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,8 +438,6 @@ func (c *Client) GetPullRequest(ctx context.Context, owner, repo string, number
|
||||
return &pr, nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
// GetPullRequestFiles fetches the list of files changed in a PR.
|
||||
func (c *Client) GetPullRequestFiles(ctx context.Context, owner, repo string, number int) ([]ChangedFile, error) {
|
||||
reqURL := fmt.Sprintf("%s/repos/%s/%s/pulls/%d/files",
|
||||
|
||||
Reference in New Issue
Block a user