test: add 10 integration tests for end-to-end pipeline verification - #33
Conversation
Add internal/reviewer/integration_test.go with enhanced capturing mocks that verify the CONTENT of VCS API payloads, not just call counts. Tests cover: - CI notes: verify summary markdown structure, severity table, emoji badges, file:line refs - CI discussions: verify inline comment positions (SHA, path, line) - CI discussions fallback: CreateDiscussion error → PostNote fallback - SARIF output: end-to-end file write with correct ruleId, level, URI, startLine across CRITICAL/MEDIUM/LOW severity mapping - Summary mode: RunSummary → PostNote with classification, intent, risk, scope, breaking changes - Explain mode: RunExplain → PostNote with formatted explanation - Intent-aware review: two-pass (Summarize + Review) with intent markdown prepended to CI note - Token budget: MaxTokens trims files from model prompt - Excluded patterns: *.pb.go, vendor/*, go.sum filtered from model - PostNote error: 403 propagated to caller Closes the 'integration tests' gap from ROADMAP v0.2.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded end-to-end reviewer integration tests covering CI notes and discussions, SARIF output, summary and explanation modes, intent-aware review, input filtering, token limits, and posting errors. ChangesReviewer integration coverage
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
internal/reviewer/integration_test.go (2)
47-57: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider consolidating with
intentMockModel.
internal/reviewer/intent_test.goalready defines a Summarize-capable double in this same package; a single shared mock would avoid drift between the two.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/reviewer/integration_test.go` around lines 47 - 57, Consolidate the Summarize-capable test double by reusing the existing intentMockModel from intent_test.go instead of defining mockSummarizeModel in integration_test.go. Preserve the summary result, error, and summarizeCalls behavior, and update integration tests to reference the shared mock.
694-703: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssertion can pass for the wrong reason.
fileCount != 5also succeeds when zero files appear in the prompt (e.g. if prompt path rendering changes), so the test can stay green while trimming is broken. Assert a bounded range instead.♻️ Tighter assertion
- if fileCount == 5 { - t.Error("expected token budget to trim some files, but all 5 were in the prompt") - } + if fileCount < 1 || fileCount >= 5 { + t.Errorf("expected budget to include some but not all files, got %d of 5", fileCount) + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/reviewer/integration_test.go` around lines 694 - 703, Update the file-count assertion in the prompt validation test to require a bounded, nonzero result: verify that at least one but fewer than all five expected files appear in prompt, rather than only checking fileCount != 5. Keep the existing file-count collection logic unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/reviewer/integration_test.go`:
- Around line 267-273: Guard d2.Position against nil before accessing NewPath or
NewLine, matching the existing d1 validation pattern. Report a test failure and
stop further d2 position assertions when it is nil, while preserving the current
field checks for non-nil positions.
---
Nitpick comments:
In `@internal/reviewer/integration_test.go`:
- Around line 47-57: Consolidate the Summarize-capable test double by reusing
the existing intentMockModel from intent_test.go instead of defining
mockSummarizeModel in integration_test.go. Preserve the summary result, error,
and summarizeCalls behavior, and update integration tests to reference the
shared mock.
- Around line 694-703: Update the file-count assertion in the prompt validation
test to require a bounded, nonzero result: verify that at least one but fewer
than all five expected files appear in prompt, rather than only checking
fileCount != 5. Keep the existing file-count collection logic unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e9dafe97-5ca4-4006-a99e-16d13889a32a
📒 Files selected for processing (1)
internal/reviewer/integration_test.go
- Guard d2.Position against nil before accessing fields (actionable) - Tighten budget assertion to bounded range 1..4 (nitpick)
What
10 integration tests that verify the content of VCS API payloads (not just call counts), SARIF output shape, and all pipeline modes end-to-end.
Closes the
Integration testsgap from ROADMAP v0.2.Tests
CINotes_PostedContentCIDiscussions_PositionsCIDiscussions_FallbackOnErrorSARIF_OutputSummary_CINoteExplain_CINoteIntentAware_CINoteTokenBudget_TrimFilesExcludedPatternsPostNoteErrorApproach
Enhanced
capturingVCSmock capturesPostNotebodies andCreateDiscussionrequests. All tests useNewWithDiffSource— zero network, zero git, zero GCP.Verification
Summary by CodeRabbit