worktrunk
worktrunk copied to clipboard
test: add unit tests for branch_tracks_ref
Summary
branch_tracks_ref in src/git/mod.rs (line ~280) is a public function with no unit tests. It handles PR/MR checkout logic — checking whether a branch tracks a specific ref — and is called from src/git/remote_ref/mod.rs and src/commands/worktree/switch.rs.
Suggested tests
- Branch tracking the expected ref (returns true)
- Branch tracking a different ref (returns false)
- Non-existent branch (returns false)
- Config read failure handling
Location
src/git/mod.rslines 280-312
@worktrunk-bot please draft this
Drafted in #1758 — adds 6 unit tests for branch_tracks_ref:
- Branch tracking the expected ref (
Some(true)) - Branch tracking a different ref (
Some(false)) - Branch with no tracking config (
Some(false)) - Nonexistent branch (
None) - Invalid repo path (
None) - GitLab MR ref variant (matching + mismatched)