fix(github): add pagination tests and fix truncation warning logic
PR Ready Gate / clear-labels (pull_request) Successful in 2s
CI / test (pull_request) Successful in 19s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 29s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 55s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m10s
PR Ready Gate / clear-labels (pull_request) Successful in 2s
CI / test (pull_request) Successful in 19s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 29s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 55s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m10s
F1: Add comprehensive pagination tests for ListReviews covering: - Multi-page behaviour (2 full + 1 partial page) - Exact-multiple-of-pageSize (extra empty-page round-trip) - maxReviewPages cutoff (cap hit, results still returned) - Empty first page (PR with no reviews) F2: Fix truncation warning logic by moving it outside the loop with a 'truncated' flag. Previously, the warning fired inline at page==maxPages which could miss the case where the short-page break fires first on the cap page. Now it only fires when the loop exits because the cap was reached and the last page was full (indicating more data likely exists). Also adds SetReviewPagination to Client for test-time override of page size and max pages, following the existing SetRetryBackoff pattern.
This commit is contained in:
@@ -110,6 +110,11 @@ type Client struct {
|
||||
// retryBackoff[i] is the delay before attempt i+1 (after attempt i fails).
|
||||
// If nil, defaults to {1s, 2s}. Set to shorter durations in tests via SetRetryBackoff.
|
||||
retryBackoff []time.Duration
|
||||
|
||||
// reviewPageSize overrides reviewsPerPage for testing. Zero means use default.
|
||||
reviewPageSize int
|
||||
// reviewMaxPages overrides maxReviewPages for testing. Zero means use default.
|
||||
reviewMaxPages int
|
||||
}
|
||||
|
||||
// defaultCheckRedirect is the redirect policy used by NewClient and SetHTTPClient(nil).
|
||||
@@ -194,6 +199,13 @@ func (c *Client) SetRetryBackoff(d []time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetReviewPagination overrides the page size and max pages for ListReviews.
|
||||
// Intended for testing only; must be called before any goroutines issue requests.
|
||||
func (c *Client) SetReviewPagination(pageSize, maxPages int) {
|
||||
c.reviewPageSize = pageSize
|
||||
c.reviewMaxPages = maxPages
|
||||
}
|
||||
|
||||
// requestOptions holds per-request configuration for doRequestCore.
|
||||
type requestOptions struct {
|
||||
// bodyFn returns a fresh io.Reader for the request body on each attempt.
|
||||
|
||||
Reference in New Issue
Block a user