worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

test: add unit tests for branch_tracks_ref

Open worktrunk-bot opened this issue 8 months ago • 2 comments

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.rs lines 280-312

worktrunk-bot avatar Mar 21 '26 06:03 worktrunk-bot

@worktrunk-bot please draft this

max-sixty avatar Mar 27 '26 00:03 max-sixty

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)

worktrunk-bot avatar Mar 27 '26 00:03 worktrunk-bot