Skip to content

Add unit tests for internal/focus package#72

Merged
greynewell merged 1 commit intomainfrom
test/focus-handler
Apr 8, 2026
Merged

Add unit tests for internal/focus package#72
greynewell merged 1 commit intomainfrom
test/focus-handler

Conversation

@greynewell
Copy link
Copy Markdown
Contributor

@greynewell greynewell commented Apr 8, 2026

Summary

The focus package had zero test coverage despite being used by both the focus CLI command and the MCP get_graph-adjacent functionality. These tests were added alongside the bug fixes in #68 (relationship type case normalization).

  • pathMatches() — exact, suffix, and ./-prefix variants
  • extract() — file lookup, imports BFS traversal, function/callee population, CalledBy population, self-call exclusion
  • Regression guard: verifies uppercase rel types (DEFINES_FUNCTION, CALLS) produce no results — documents and locks in the fix(focus,find): fix relationship type case, empty CalledBy/Imports, stale API #68 fix
  • render() — JSON and markdown output modes

Test plan

  • go test ./internal/focus/... — 19 tests, all pass
  • go build ./... passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for focus handler functionality to improve code quality and reliability.

The focus package had zero test coverage. New tests cover:
- pathMatches() helper (exact, suffix, dot-slash prefix)
- extract() core logic: file lookup, imports BFS, functions/callees,
  CalledBy population, self-call exclusion
- Relationship type case regression guard: verifies uppercase rel types
  (DEFINES_FUNCTION, CALLS) do not match, confirming the #68 fix
- render() for both JSON and markdown output formats

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 828944ba-3394-48c2-9447-d43c5ba05b00

📥 Commits

Reviewing files that changed from the base of the PR and between 4dad082 and 18b7823.

📒 Files selected for processing (1)
  • internal/focus/handler_test.go

Walkthrough

A new test file was added to comprehensively test the focus handler's internal functions: pathMatches (path matching logic), extract (analyzing code and extracting relationships), and render (outputting JSON and Markdown). The tests cover normal cases, edge cases, and various configurations.

Changes

Cohort / File(s) Summary
Focus Handler Tests
internal/focus/handler_test.go
New 304-line test suite covering pathMatches behavior with various path formats, extract function logic for imports and call relationships (including self-call exclusion), and render output for both JSON and Markdown formats.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jonathanpopham

Poem

🔍 A test file arrives with focus so keen,
Pathmatches, extracts, renders so clean,
From JSON to Markdown, no stone left unturned,
Edge cases and callers now fully confirmed! ✨

✨ 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 test/focus-handler

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

@greynewell greynewell merged commit ee31df0 into main Apr 8, 2026
6 of 7 checks passed
@greynewell greynewell deleted the test/focus-handler branch April 8, 2026 20:03
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