@@ -43,31 +43,42 @@ func TestFromPath(t *testing.T) {
4343 })
4444
4545 t .Run ("when path contains a symlink" , func (t * testing.T ) {
46- mockPathwrap := new (pathwrap.MockPath )
47- mockGit := new (git.MockGit )
48- mockHome := new (home.MockHome )
49- n := NewNamer (mockPathwrap , mockGit , mockHome )
50-
5146 t .Run ("name for symlinked file in symlinked git repo" , func (t * testing.T ) {
47+ mockPathwrap := new (pathwrap.MockPath )
48+ mockGit := new (git.MockGit )
49+ mockHome := new (home.MockHome )
50+ n := NewNamer (mockPathwrap , mockGit , mockHome )
5251 mockPathwrap .On ("EvalSymlinks" , "/Users/josh/d/.c/neovim" ).Return ("/Users/josh/dotfiles/.config/neovim" , nil )
52+ mockGit .On ("WorktreeList" , "/Users/josh/dotfiles/.config/neovim" ).Return (false , "" , nil )
5353 mockGit .On ("ShowTopLevel" , "/Users/josh/dotfiles/.config/neovim" ).Return (true , "/Users/josh/dotfiles" , nil )
5454 mockGit .On ("GitCommonDir" , "/Users/josh/dotfiles/.config/neovim" ).Return (true , "" , nil )
5555 mockPathwrap .On ("Base" , "/Users/josh/dotfiles" ).Return ("dotfiles" )
5656 name , _ := n .Name ("/Users/josh/d/.c/neovim" )
5757 assert .Equal (t , "dotfiles/_config/neovim" , name )
5858 })
5959
60- t .Run ("name for git worktree" , func (t * testing.T ) {
60+ t .Run ("name for git bare repo" , func (t * testing.T ) {
61+ mockPathwrap := new (pathwrap.MockPath )
62+ mockGit := new (git.MockGit )
63+ mockHome := new (home.MockHome )
64+ n := NewNamer (mockPathwrap , mockGit , mockHome )
6165 mockPathwrap .On ("EvalSymlinks" , "/Users/josh/p/sesh/main" ).Return ("/Users/josh/projects/sesh/main" , nil )
62- mockGit .On ("ShowTopLevel" , "/Users/josh/projects/sesh/main" ).Return (true , "/Users/josh/projects/sesh/main" , nil )
63- mockGit .On ("GitCommonDir" , "/Users/josh/projects/sesh/main" ).Return (true , "/Users/josh/projects/sesh/.bare" , nil )
66+ mockGit .On ("WorktreeList" , "/Users/josh/projects/sesh/main" ).Return (true , `/Users/josh/projects/sesh/.bare (bare)
67+ /Users/josh/projects/sesh/main ba04ca494 [main]
68+ ` , nil )
6469 mockPathwrap .On ("Base" , "/Users/josh/projects/sesh" ).Return ("sesh" )
6570 name , _ := n .Name ("/Users/josh/p/sesh/main" )
6671 assert .Equal (t , "sesh/main" , name )
6772 })
6873
6974 t .Run ("returns base on non-git dir" , func (t * testing.T ) {
75+ mockPathwrap := new (pathwrap.MockPath )
76+ mockGit := new (git.MockGit )
77+ mockHome := new (home.MockHome )
78+ n := NewNamer (mockPathwrap , mockGit , mockHome )
7079 mockPathwrap .On ("EvalSymlinks" , "/Users/josh/c/neovim" ).Return ("/Users/josh/.config/neovim" , nil )
80+ mockGit .On ("WorktreeList" , "/Users/josh/.config/neovim" ).Return (true , `/Users/josh/.config/neovim c1d2e3f45 [main]
81+ ` , nil )
7182 mockGit .On ("ShowTopLevel" , "/Users/josh/.config/neovim" ).Return (false , "" , fmt .Errorf ("not a git repository (or any of the parent" ))
7283 mockGit .On ("GitCommonDir" , "/Users/josh/.config/neovim" ).Return (false , "" , fmt .Errorf ("not a git repository (or any of the parent" ))
7384 mockPathwrap .On ("Base" , "/Users/josh/.config/neovim" ).Return ("neovim" )
0 commit comments