File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,10 +51,34 @@ test_cd_works_with_slashed_branch() {
5151 assert_contains " $PWD " " feature/auth" " Should work with slashed branch name"
5252}
5353
54+ test_cd_works_with_nonstandard_location () {
55+ # Create worktree manually in non-standard location (not in .worktrees/)
56+ local custom_path=" $TEST_TEMP /custom-location/my-worktree"
57+ mkdir -p " $( dirname " $custom_path " ) "
58+ cd " $TEST_TEMP /main"
59+ git worktree add -b custom-branch " $custom_path " > /dev/null 2>&1
60+
61+ wt cd custom-branch
62+ assert_contains " $PWD " " custom-location/my-worktree" " Should find worktree in non-standard location"
63+ }
64+
65+ test_cd_works_with_deeply_nested_nonstandard () {
66+ # Create worktree in deeply nested non-standard location
67+ local custom_path=" $TEST_TEMP /some/deep/nested/path/worktree"
68+ mkdir -p " $( dirname " $custom_path " ) "
69+ cd " $TEST_TEMP /main"
70+ git worktree add -b nested-branch " $custom_path " > /dev/null 2>&1
71+
72+ wt cd nested-branch
73+ assert_contains " $PWD " " some/deep/nested/path/worktree" " Should find deeply nested worktree"
74+ }
75+
5476# Register tests
5577run_test " wt cd changes to worktree" test_cd_changes_to_worktree
5678run_test " wt cd without arg goes to main" test_cd_no_arg_goes_to_main
5779run_test " wt cd fails for nonexistent worktree" test_cd_fails_for_nonexistent
5880run_test " wt cd works with short name" test_cd_works_with_short_name
5981run_test " wt cd works with full path" test_cd_works_with_full_path
6082run_test " wt cd works with slashed branch" test_cd_works_with_slashed_branch
83+ run_test " wt cd works with nonstandard location" test_cd_works_with_nonstandard_location
84+ run_test " wt cd works with deeply nested nonstandard" test_cd_works_with_deeply_nested_nonstandard
Original file line number Diff line number Diff line change @@ -72,6 +72,18 @@ test_rm_with_full_path() {
7272 assert_success " Should remove worktree by full path"
7373}
7474
75+ test_rm_works_with_nonstandard_location () {
76+ # Create worktree manually in non-standard location
77+ local custom_path=" $TEST_TEMP /custom-location/my-worktree"
78+ mkdir -p " $( dirname " $custom_path " ) "
79+ cd " $TEST_TEMP /main"
80+ git worktree add -b custom-branch " $custom_path " > /dev/null 2>&1
81+
82+ wt rm custom-branch > /dev/null 2>&1
83+ [[ ! -d " $custom_path " ]]
84+ assert_success " Should remove worktree in non-standard location"
85+ }
86+
7587# Register tests
7688run_test " wt rm removes clean worktree" test_rm_removes_clean_worktree
7789run_test " wt rm warns on dirty worktree" test_rm_warns_on_dirty_worktree
@@ -81,3 +93,4 @@ run_test "wt rm without arg removes current" test_rm_current_worktree_no_arg
8193run_test " wt rm cds back to main" test_rm_current_worktree_cds_to_main
8294run_test " wt rm fails for nonexistent" test_rm_fails_for_nonexistent
8395run_test " wt rm with full path" test_rm_with_full_path
96+ run_test " wt rm works with nonstandard location" test_rm_works_with_nonstandard_location
You can’t perform that action at this time.
0 commit comments