MCPcopy Create free account
hub / github.com/cli/cli / TestClientWorktreesListsRepositoryWorktrees

Function TestClientWorktreesListsRepositoryWorktrees

git/client_test.go:2027–2046  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2025}
2026
2027func TestClientWorktreesListsRepositoryWorktrees(t *testing.T) {
2028 // Given a repository with a linked feature worktree
2029 repo := newTestRepo(t)
2030 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "initial commit")
2031 repo.run(t, "branch", "feature")
2032 worktreeParent, err := filepath.EvalSymlinks(t.TempDir())
2033 require.NoError(t, err)
2034 worktreeDir := filepath.Join(worktreeParent, "feature")
2035 repo.run(t, "worktree", "add", "--quiet", worktreeDir, "feature")
2036
2037 // When repository worktrees are listed
2038 worktrees, err := repo.client.Worktrees(t.Context())
2039
2040 // Then the primary and linked worktrees are returned with their refs
2041 require.NoError(t, err)
2042 assert.Equal(t, []Worktree{
2043 {Path: filepath.ToSlash(repo.dir), Ref: "refs/heads/trunk"},
2044 {Path: filepath.ToSlash(worktreeDir), Ref: "refs/heads/feature"},
2045 }, worktrees)
2046}
2047
2048func TestClientWorktreeRemoveRemovesOptionLikePath(t *testing.T) {
2049 // Given a linked worktree whose relative path begins with a dash

Callers

nothing calls this directly

Calls 5

newTestRepoFunction · 0.85
JoinMethod · 0.80
EqualMethod · 0.80
WorktreesMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected