Skip to content

Commit 7980268

Browse files
committed
test(destroy): add matching resolution tests for destroy command
Add relative path, multiple by name, and invalid name error tests to mirror the remove test coverage.
1 parent 7028937 commit 7980268

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/destroy.bats

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,37 @@ teardown() {
114114
assert_worktree_not_exists "$TEST_DIR/destroy-by-name"
115115
assert_branch_not_exists "destroy-by-name"
116116
}
117+
118+
@test "destroy: resolves worktree by relative path" {
119+
init_repo myrepo
120+
cd myrepo
121+
create_worktree ../destroy-rel destroy-rel
122+
123+
echo "y" | "$GIT_WT" destroy ../destroy-rel
124+
125+
assert_worktree_not_exists "$TEST_DIR/destroy-rel"
126+
assert_branch_not_exists "destroy-rel"
127+
}
128+
129+
@test "destroy: resolves multiple worktrees by name" {
130+
init_repo myrepo
131+
cd myrepo
132+
create_worktree ../dest-name-one dest-name-one
133+
create_worktree ../dest-name-two dest-name-two
134+
135+
echo "y" | "$GIT_WT" destroy dest-name-one dest-name-two
136+
137+
assert_worktree_not_exists "$TEST_DIR/dest-name-one"
138+
assert_worktree_not_exists "$TEST_DIR/dest-name-two"
139+
}
140+
141+
@test "destroy: invalid name lists available worktrees" {
142+
init_repo myrepo
143+
cd myrepo
144+
create_worktree ../some-dest some-dest
145+
146+
run "$GIT_WT" destroy no-such-wt
147+
[ "$status" -ne 0 ]
148+
[[ "$output" == *"Available worktrees:"* ]]
149+
[[ "$output" == *"some-dest"* ]]
150+
}

0 commit comments

Comments
 (0)