(t *testing.T)
| 190 | } |
| 191 | |
| 192 | func TestListWorktrees(t *testing.T) { |
| 193 | t.Run("lists worktrees including main", func(t *testing.T) { |
| 194 | dir := initTestRepo(t) |
| 195 | wtPath := filepath.Join(dir, "worktrees", "test-prd") |
| 196 | |
| 197 | if err := CreateWorktree(dir, wtPath, "chief/test-prd"); err != nil { |
| 198 | t.Fatalf("CreateWorktree() error = %v", err) |
| 199 | } |
| 200 | |
| 201 | worktrees, err := ListWorktrees(dir) |
| 202 | if err != nil { |
| 203 | t.Fatalf("ListWorktrees() error = %v", err) |
| 204 | } |
| 205 | |
| 206 | if len(worktrees) < 2 { |
| 207 | t.Fatalf("expected at least 2 worktrees, got %d", len(worktrees)) |
| 208 | } |
| 209 | |
| 210 | // Find our worktree |
| 211 | found := false |
| 212 | for _, wt := range worktrees { |
| 213 | if wt.Branch == "chief/test-prd" { |
| 214 | found = true |
| 215 | if wt.HEAD == "" { |
| 216 | t.Error("worktree HEAD is empty") |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | if !found { |
| 221 | t.Error("worktree with branch chief/test-prd not found in list") |
| 222 | } |
| 223 | }) |
| 224 | } |
| 225 | |
| 226 | func TestIsWorktree(t *testing.T) { |
| 227 | t.Run("returns true for valid worktree", func(t *testing.T) { |
nothing calls this directly
no test coverage detected