test: add mocked Forgejo and model coverage #11
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
nimmo/forgejo-auto-pr-review!11
Loading…
Reference in a new issue
No description provided.
Delete branch "test/issue-8-forgejo-fixtures"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements the main test-foundation slice of #8.
Adds offline coverage for Forgejo request/config/diff/publishing paths, Ollama request and error handling, prompt-injection containment, deterministic-check limits, event dispatch, and the full-SHA regression found during rollout.
Validation:
python3 -W error::ResourceWarning -m unittest discover -s tests(20 passing).Automated code review
Reviewed commit:
81853a5e78a83b69ea33e9e30939886b0bf8c704Verdict: Requires further work
Resolve the blocking or important findings and investigate failed deterministic checks before merging.
Overall assessment
The pull request adds comprehensive unit tests and mock coverage for the Forgejo AI PR reviewer, including fixtures, API interaction mocks, diff handling, Ollama integration, error handling, and workflow validation. It also updates the workflow file to pin a new action revision and improves error messages in bounded_diff.
Blocking findings
The workflow uses commit SHA
fc1861af45, but test_self_review_workflow_pins_a_full_action_revision only verifies a 40-character hex string exists via regex match (re.search(r"forgejo-auto-pr-review@([0-9a-f]+)", workflow)), not the exact value.Impact: The test does not ensure the workflow is pinned to the intended revision, allowing potential drift or incorrect updates without detection.
Suggested fix: Update the test to assert the exact SHA value (
fc1861af45) rather than just checking for a 40-character hex string.Important findings
Missing test coverage for exact boundary in bounded_diff truncation (tests/test_reviewer.py:120; high confidence)
The test 'test_bounded_diff_reports_truncation_and_sets_authentication' includes a case where diff length (4 bytes) equals max_bytes (4), but the assertion expects truncated=False. This does not clarify whether truncation occurs at > or >= limit.
Impact: Ambiguity in boundary condition handling could cause inconsistent truncation behavior in production, leading to either over-truncation or under-truncation of diffs.
Suggested fix: Add explicit test cases for diff lengths of (max_bytes - 1), max_bytes, and (max_bytes + 1) to ensure deterministic truncation logic at boundaries.
Test does not verify timeout handling in bounded_diff (tests/test_reviewer.py:120; high confidence)
The test 'test_bounded_diff_reports_truncation_and_sets_authentication' mocks urllib.request.urlopen but does not cover cases where urlopen raises urllib.error.URLError with a timeout. However, the diff shows that bounded_diff now includes try/except handling for URLError and raises RuntimeError.
Impact: Missing coverage for network timeouts in bounded_diff could lead to unhandled exceptions during diff fetching, causing reviewer failures.
Suggested fix: Add a test case that mocks urlopen to raise urllib.error.URLError(TimeoutError(...)) and verifies appropriate handling (e.g., raising RuntimeError or returning empty diff).
Suggestions
None.
Tests and validation
Questions
Review limitations
Review metadata
nimmo referenced this pull request2026-07-20 17:24:04 +01:00