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

Function TestWorktreeForBranchRejectsNonMatchingBranch

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

Source from the content-addressed store, hash-verified

1998}
1999
2000func TestWorktreeForBranchRejectsNonMatchingBranch(t *testing.T) {
2001 worktrees := []Worktree{
2002 {Path: "/path/to/main", Ref: "refs/heads/main"},
2003 {Path: "/path/to/feature", Ref: "refs/heads/feature/one"},
2004 }
2005 tests := []struct {
2006 name string
2007 branch string
2008 }{
2009 {name: "partial branch name", branch: "feature"},
2010 {name: "missing branch", branch: "missing"},
2011 }
2012
2013 for _, tt := range tests {
2014 t.Run(tt.name, func(t *testing.T) {
2015 // Given worktrees without the exact requested branch
2016 branch := tt.branch
2017
2018 // When the branch is located
2019 worktree := WorktreeForBranch(worktrees, branch)
2020
2021 // Then no worktree is returned
2022 assert.Nil(t, worktree)
2023 })
2024 }
2025}
2026
2027func TestClientWorktreesListsRepositoryWorktrees(t *testing.T) {
2028 // Given a repository with a linked feature worktree

Callers

nothing calls this directly

Calls 2

WorktreeForBranchFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected