wfxr.forgit/tests/empty-state.test.sh
Wenxuan Zhang 3b9ebce8bc refactor: extract _forgit_print_dim helper and improve worktree ops
- Extract dim formatting into _forgit_print_dim() to replace hardcoded
  ANSI sequences in _forgit_branch_list()
- Add empty state check and alt-l lock toggle reload for worktree delete
- Fix worktree path completion to handle paths with spaces using -z flag
- Add worktree command completion for bash and zsh
2026-03-10 09:20:16 +08:00

41 lines
1.1 KiB
Bash

#!/usr/bin/env bash
function set_up_before_script() {
source bin/git-forgit
# Ignore global git config files
export GIT_CONFIG_SYSTEM=/dev/null
export GIT_CONFIG_GLOBAL=/dev/null
# Create a temporary git repository for testing
cd "$(bashunit::temp_dir)" || return 1
git init -q
git config user.email "test@example.com"
git config user.name "Test User"
# Create an initial commit so we have a valid repo
echo "initial" > README.md
git add README.md
git commit -q -m "Initial commit"
}
function test_checkout_file_shows_message_when_no_modified_files() {
output=$(_forgit_checkout_file 2>&1)
assert_general_error
assert_same "Nothing to checkout." "$output"
}
function test_checkout_tag_shows_message_when_no_tags() {
output=$(_forgit_checkout_tag 2>&1)
assert_general_error
assert_same "Nothing to checkout: there are no tags." "$output"
}
function test_worktree_delete_shows_message_when_no_deletable_worktrees() {
output=$(_forgit_worktree_delete 2>&1)
assert_general_error
assert_same "Nothing to delete." "$output"
}