MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / TestListWorktrees

Function TestListWorktrees

internal/git/worktree_test.go:192–224  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

190}
191
192func 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
226func TestIsWorktree(t *testing.T) {
227 t.Run("returns true for valid worktree", func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

initTestRepoFunction · 0.85
CreateWorktreeFunction · 0.85
ListWorktreesFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected