Skip to content

test: add 10 integration tests for end-to-end pipeline verification - #33

Merged
brucearctor merged 2 commits into
mainfrom
feat/integration-tests
Jul 25, 2026
Merged

test: add 10 integration tests for end-to-end pipeline verification#33
brucearctor merged 2 commits into
mainfrom
feat/integration-tests

Conversation

@brucearctor

@brucearctor brucearctor commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

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 tests gap from ROADMAP v0.2.

Tests

# Test Pipeline What it verifies
1 CINotes_PostedContent Run → PostNote Summary markdown: severity table, emoji badges, file:line refs
2 CIDiscussions_Positions Run → CreateDiscussion Inline comment SHA/path/line positions
3 CIDiscussions_FallbackOnError Run → CreateDiscussion → PostNote Discussion error → fallback note with file:line prefix
4 SARIF_Output Run → WriteSARIF File I/O: ruleId, level mapping, URI, startLine
5 Summary_CINote RunSummary → PostNote Classification, intent, risk, scope, breaking changes
6 Explain_CINote RunExplain → PostNote Formatted explanation content
7 IntentAware_CINote Run (two-pass) → PostNote Intent markdown prepended to review summary
8 TokenBudget_TrimFiles Run MaxTokens trims files from model prompt
9 ExcludedPatterns Run .pb.go, vendor/, go.sum filtered
10 PostNoteError Run → PostNote 403 error propagated to caller

Approach

Enhanced capturingVCS mock captures PostNote bodies and CreateDiscussion requests. All tests use NewWithDiffSource — zero network, zero git, zero GCP.

Verification

go test ./... -race -count=1  → all pass
golangci-lint run             → 0 issues

Summary by CodeRabbit

  • Tests
    • Added comprehensive end-to-end coverage for CI review notes, inline discussions, fallback behavior, SARIF output, summaries, explanations, and intent-aware reviews.
    • Added validation for token-budget trimming, excluded files, discussion positioning, severity mapping, deduplicated categories, and error reporting.
    • Expanded verification of generated review content, including findings, confidence, risk, scope, inferred intent, and structured output.

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.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e9ae8cb-3564-41b7-9930-506daf268f9d

📥 Commits

Reviewing files that changed from the base of the PR and between 1920c10 and 3782b17.

📒 Files selected for processing (1)
  • internal/reviewer/integration_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/reviewer/integration_test.go

📝 Walkthrough

Walkthrough

Added 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.

Changes

Reviewer integration coverage

Layer / File(s) Summary
Integration test harness
internal/reviewer/integration_test.go
Adds VCS and model test doubles plus shared diff and CI configuration fixtures.
CI notes and discussions
internal/reviewer/integration_test.go
Validates note content, discussion positions, severity markup, cleanup, and fallback notes when discussion creation fails.
SARIF output validation
internal/reviewer/integration_test.go
Checks generated SARIF metadata, result counts, severity mappings, and deduplicated rules.
Summary, explanation, and intent review
internal/reviewer/integration_test.go
Validates summary and explanation notes, model call counts, and intent-aware two-pass output.
Input limits and posting errors
internal/reviewer/integration_test.go
Tests token-budget trimming, excluded file patterns, and contextual PostNote error propagation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: adding integration tests for end-to-end pipeline verification.
Description check ✅ Passed The description covers the main goals, test coverage, implementation approach, and verification results, with only minor template differences.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/integration-tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
internal/reviewer/integration_test.go (2)

47-57: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider consolidating with intentMockModel.

internal/reviewer/intent_test.go already 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 win

Assertion can pass for the wrong reason.

fileCount != 5 also 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

📥 Commits

Reviewing files that changed from the base of the PR and between f9361ff and 1920c10.

📒 Files selected for processing (1)
  • internal/reviewer/integration_test.go

Comment thread internal/reviewer/integration_test.go
- Guard d2.Position against nil before accessing fields (actionable)
- Tighten budget assertion to bounded range 1..4 (nitpick)
@brucearctor
brucearctor merged commit 0a2936a into main Jul 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant