mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-17 22:14:08 +00:00
refactor(tests): Phase 3 - Move native tests to new structure
- Copy Unix and Windows tests to native/ directories - Update Unix tests to source shared helpers - Remove Section 10 (npm tests) from native tests - Update final results to use shared helper functions
This commit is contained in:
1 parent
7aa01eb5f7
commit
66e93fcae1
7 files changed
+2957
No files matched your search
Executable
+280
@@ -0,0 +1,280 @@
|
||||
#!/usr/bin/env bash
|
||||
# CCS Native Unix Tests
|
||||
# Tests for native installation method (curl | bash)
|
||||
# This is part of the restructured test suite
|
||||
|
||||
set +e # Don't exit on errors, we're testing
|
||||
|
||||
# Source shared utilities
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../../shared/helpers.sh"
|
||||
|
||||
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
echo -e "${YELLOW}CCS COMPREHENSIVE EDGE CASE TESTING${NC}"
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Clean installation
|
||||
echo -e "${CYAN}Preparing clean environment...${NC}"
|
||||
rm -rf ~/.ccs
|
||||
rm -rf /tmp/ccs-test
|
||||
|
||||
# Extract and install
|
||||
mkdir -p /tmp/ccs-test
|
||||
tar -xzf /tmp/ccs-v2.1.1-final.tar.gz -C /tmp/ccs-test
|
||||
cd /tmp/ccs-test
|
||||
bash ./installers/install.sh > /dev/null 2>&1
|
||||
|
||||
# On Linux/macOS, ccs is a symlink in ~/.local/bin
|
||||
CCS_PATH="$HOME/.local/bin/ccs"
|
||||
|
||||
if [[ ! -L "$CCS_PATH" ]] && [[ ! -f "$CCS_PATH" ]]; then
|
||||
echo -e "${RED}FATAL: Installation failed, ccs not found at $CCS_PATH${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Installation complete, starting tests...${NC}"
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 1: VERSION COMMANDS
|
||||
# ============================================================================
|
||||
echo -e "${YELLOW}===== SECTION 1: VERSION COMMANDS =====${NC}"
|
||||
|
||||
test_case "Version flag --version" "Shows CCS version 2.1.1" bash -c "
|
||||
output=\$('$CCS_PATH' --version 2>&1)
|
||||
[[ \$output =~ 2\\.1\\.1|CCS ]]
|
||||
"
|
||||
|
||||
test_case "Version flag -v" "Shows CCS version 2.1.1" bash -c "
|
||||
output=\$('$CCS_PATH' -v 2>&1)
|
||||
[[ \$output =~ 2\\.1\\.1|CCS ]]
|
||||
"
|
||||
|
||||
test_case "Version command (word)" "Shows CCS version 2.1.1" bash -c "
|
||||
output=\$('$CCS_PATH' version 2>&1)
|
||||
[[ \$output =~ 2\\.1\\.1|CCS ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 2: HELP COMMANDS
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 2: HELP COMMANDS =====${NC}"
|
||||
|
||||
test_case "Help flag --help" "Shows help without profile error" bash -c "
|
||||
output=\$('$CCS_PATH' --help 2>&1)
|
||||
[[ \$output =~ Usage|Claude ]]
|
||||
"
|
||||
|
||||
test_case "Help flag -h" "Shows help without profile error" bash -c "
|
||||
output=\$('$CCS_PATH' -h 2>&1)
|
||||
[[ \$output =~ Usage|Claude ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 3: ARGUMENT PARSING - THE CRITICAL FIX
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 3: ARGUMENT PARSING (CRITICAL FIX) =====${NC}"
|
||||
|
||||
test_case "Single flag: -c" "Does NOT show 'Profile -c not found' error" bash -c "
|
||||
output=\$('$CCS_PATH' -c 2>&1)
|
||||
! [[ \$output =~ Profile.*\'-c\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Single flag: --verbose" "Does NOT show 'Profile --verbose not found' error" bash -c "
|
||||
output=\$('$CCS_PATH' --verbose 2>&1)
|
||||
! [[ \$output =~ Profile.*\'--verbose\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Single flag: -p" "Does NOT show 'Profile -p not found' error" bash -c "
|
||||
output=\$('$CCS_PATH' -p test 2>&1)
|
||||
! [[ \$output =~ Profile.*\'-p\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Single flag: --debug" "Does NOT show profile error" bash -c "
|
||||
output=\$('$CCS_PATH' --debug 2>&1)
|
||||
! [[ \$output =~ Profile.*\'--debug\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Multiple flags: -c --verbose" "Accepts multiple flags without profile error" bash -c "
|
||||
output=\$('$CCS_PATH' -c --verbose 2>&1)
|
||||
! [[ \$output =~ Profile.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Flag with value: -p 'test prompt'" "Handles flag with quoted value" bash -c "
|
||||
output=\$('$CCS_PATH' -p 'test prompt' 2>&1)
|
||||
! [[ \$output =~ Profile.*\'-p\'.*not\ found ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 4: PROFILE COMMANDS
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 4: PROFILE COMMANDS =====${NC}"
|
||||
|
||||
test_case "Default profile (no args)" "Uses default profile without error" bash -c "
|
||||
output=\$('$CCS_PATH' 2>&1)
|
||||
! [[ \$output =~ Profile.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "GLM profile" "GLM profile exists and loads" bash -c "
|
||||
output=\$('$CCS_PATH' glm 2>&1)
|
||||
! [[ \$output =~ Profile.*\'glm\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Profile with flag: glm -c" "Profile + flag combination works" bash -c "
|
||||
output=\$('$CCS_PATH' glm -c 2>&1)
|
||||
! [[ \$output =~ Profile.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Profile with multiple flags: glm -c --verbose" "Profile + multiple flags works" bash -c "
|
||||
output=\$('$CCS_PATH' glm -c --verbose 2>&1)
|
||||
! [[ \$output =~ Profile.*not\ found ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 5: ERROR HANDLING
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 5: ERROR HANDLING =====${NC}"
|
||||
|
||||
test_case "Invalid profile name" "Shows helpful error for invalid profile" bash -c "
|
||||
output=\$('$CCS_PATH' nonexistent-profile 2>&1)
|
||||
[[ \$output =~ Profile.*not\ found ]] && [[ \$output =~ Available\ profiles ]]
|
||||
"
|
||||
|
||||
test_case "Invalid profile with special chars" "Rejects invalid characters in profile name" bash -c "
|
||||
output=\$('$CCS_PATH' 'test@profile' 2>&1)
|
||||
[[ \$output =~ Invalid\ profile\ name|not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Empty string as profile" "Shows error for empty profile name" bash -c "
|
||||
output=\$('$CCS_PATH' '' 2>&1)
|
||||
# In bash, '' is passed as a literal argument, so it should show profile not found
|
||||
[[ \$output =~ Profile.*not\ found ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 6: EDGE CASES
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 6: EDGE CASES =====${NC}"
|
||||
|
||||
test_case "Flag starting with double dash: --test-flag" "Handles double-dash flags correctly" bash -c "
|
||||
output=\$('$CCS_PATH' --test-flag 2>&1)
|
||||
! [[ \$output =~ Profile.*\'--test-flag\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Short flag alone: -d" "Handles short flags correctly" bash -c "
|
||||
output=\$('$CCS_PATH' -d 2>&1)
|
||||
! [[ \$output =~ Profile.*\'-d\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Mixed flags and arguments" "Handles complex flag combinations" bash -c "
|
||||
output=\$('$CCS_PATH' -p test --verbose -c 2>&1)
|
||||
! [[ \$output =~ Profile.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Profile 'default' explicitly" "Explicit default profile works" bash -c "
|
||||
output=\$('$CCS_PATH' default 2>&1)
|
||||
! [[ \$output =~ Profile.*\'default\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Flag with equals: --model=gpt4" "Handles flags with equals syntax" bash -c "
|
||||
output=\$('$CCS_PATH' --model=test 2>&1)
|
||||
! [[ \$output =~ Profile.*\'--model=test\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Negative number (looks like flag): -1" "Handles numeric flags" bash -c "
|
||||
output=\$('$CCS_PATH' -1 2>&1)
|
||||
! [[ \$output =~ Profile.*\'-1\'.*not\ found ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 7: CONFIGURATION VALIDATION
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 7: CONFIGURATION VALIDATION =====${NC}"
|
||||
|
||||
test_case "Config file exists" "config.json was created" bash -c "
|
||||
[[ -f ~/.ccs/config.json ]]
|
||||
"
|
||||
|
||||
test_case "Config file is valid JSON" "config.json is valid JSON with profiles" bash -c "
|
||||
jq -e '.profiles' ~/.ccs/config.json > /dev/null 2>&1
|
||||
"
|
||||
|
||||
test_case "GLM profile file exists" "glm.settings.json exists" bash -c "
|
||||
[[ -f ~/.ccs/glm.settings.json ]]
|
||||
"
|
||||
|
||||
test_case "GLM settings is valid JSON" "glm.settings.json is valid JSON" bash -c "
|
||||
jq -e '.' ~/.ccs/glm.settings.json > /dev/null 2>&1
|
||||
"
|
||||
|
||||
test_case "VERSION file exists" "VERSION file was installed" bash -c "
|
||||
[[ -f ~/.ccs/VERSION ]]
|
||||
"
|
||||
|
||||
test_case "VERSION file has correct version" "VERSION file contains 2.1.1" bash -c "
|
||||
[[ \$(cat ~/.ccs/VERSION) == '2.1.1' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 8: REAL USAGE SIMULATION
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 8: REAL USAGE SIMULATION =====${NC}"
|
||||
|
||||
test_case "Simulate: continue conversation" "Real usage: ccs -c (continue) works" bash -c "
|
||||
output=\$('$CCS_PATH' -c 2>&1 | head -10)
|
||||
! [[ \$output =~ Profile.*\'-c\'.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Simulate: GLM with prompt" "Real usage: ccs glm -p works" bash -c "
|
||||
# Use timeout to prevent hanging
|
||||
output=\$(timeout 5s '$CCS_PATH' glm -p '2+2' 2>&1 || true)
|
||||
! [[ \$output =~ Profile.*not\ found ]]
|
||||
"
|
||||
|
||||
test_case "Simulate: verbose mode" "Real usage: ccs --verbose works" bash -c "
|
||||
output=\$('$CCS_PATH' --verbose 2>&1 | head -5)
|
||||
! [[ \$output =~ Profile.*\'--verbose\'.*not\ found ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 9: BASH-SPECIFIC EDGE CASES
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 9: BASH-SPECIFIC EDGE CASES =====${NC}"
|
||||
|
||||
test_case "Script is executable" "ccs script has execute permissions" bash -c "
|
||||
[[ -x '$CCS_PATH' ]]
|
||||
"
|
||||
|
||||
test_case "Shebang is correct" "Script has proper shebang" bash -c "
|
||||
head -1 '$CCS_PATH' | grep -q '#!/usr/bin/env bash'
|
||||
"
|
||||
|
||||
test_case "Symlink exists in PATH" "ccs symlink exists" bash -c "
|
||||
[[ -L ~/.local/bin/ccs ]] || [[ -f ~/.local/bin/ccs ]]
|
||||
"
|
||||
|
||||
test_case "Version without ./ prefix" "Can run 'ccs --version' from PATH" bash -c "
|
||||
# Check if ccs is in PATH
|
||||
output=\$(ccs --version 2>&1 || true)
|
||||
[[ \$output =~ 2\\.1\\.1|CCS ]] || [[ \$output =~ 'command not found' ]]
|
||||
# Pass if version works OR if not in PATH yet (fresh install)
|
||||
[[ \$output =~ 2\\.1\\.1|CCS ]] || [[ \$output =~ 'command not found' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
|
||||
# ============================================================================
|
||||
# FINAL RESULTS
|
||||
# ============================================================================
|
||||
print_test_summary
|
||||
print_final_result
|
||||
Executable
+446
@@ -0,0 +1,446 @@
|
||||
#!/usr/bin/env bash
|
||||
# CCS --install Functionality Testing (Linux/macOS)
|
||||
# Comprehensive tests for the --install command
|
||||
|
||||
set +e # Don't exit on errors, we're testing
|
||||
PASS_COUNT=0
|
||||
FAIL_COUNT=0
|
||||
TOTAL_TESTS=0
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
GRAY='\033[0;37m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Get script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
CCS_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
CCS_PATH="$CCS_ROOT/ccs"
|
||||
|
||||
# Backup/restore paths
|
||||
CLAUDE_DIR="$HOME/.claude"
|
||||
BACKUP_DIR="/tmp/ccs-test-backup-$(date +%s)"
|
||||
TEST_HOME="/tmp/ccs-test-home"
|
||||
TEST_CLAUDE_DIR="$TEST_HOME/.claude"
|
||||
|
||||
test_case() {
|
||||
local name="$1"
|
||||
local expected="$2"
|
||||
shift 2
|
||||
|
||||
((TOTAL_TESTS++))
|
||||
echo ""
|
||||
echo -e "${CYAN}[$TOTAL_TESTS] $name${NC}"
|
||||
echo -e "${GRAY} Expected: $expected${NC}"
|
||||
|
||||
if "$@"; then
|
||||
echo -e "${GREEN} Result: PASS${NC}"
|
||||
((PASS_COUNT++))
|
||||
return 0
|
||||
else
|
||||
echo -e "${RED} Result: FAIL${NC}"
|
||||
((FAIL_COUNT++))
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup_and_restore() {
|
||||
echo ""
|
||||
echo -e "${YELLOW}Cleaning up and restoring...${NC}"
|
||||
|
||||
# Remove test directory
|
||||
rm -rf "$TEST_HOME"
|
||||
|
||||
# Restore backup if it exists
|
||||
if [[ -d "$BACKUP_DIR" ]]; then
|
||||
if [[ -d "$CLAUDE_DIR" ]]; then
|
||||
echo " Removing test data from $CLAUDE_DIR"
|
||||
rm -rf "$CLAUDE_DIR"
|
||||
fi
|
||||
echo " Restoring backup from $BACKUP_DIR"
|
||||
mv "$BACKUP_DIR" "$CLAUDE_DIR"
|
||||
echo -e "${GREEN} Backup restored successfully${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Trap to ensure cleanup happens even if script fails
|
||||
trap cleanup_and_restore EXIT
|
||||
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
echo -e "${YELLOW}CCS --INSTALL FUNCTIONALITY TESTING${NC}"
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# SAFETY: BACKUP EXISTING ~/.claude/
|
||||
# ============================================================================
|
||||
echo -e "${CYAN}Safety: Backing up existing ~/.claude/...${NC}"
|
||||
|
||||
if [[ -d "$CLAUDE_DIR" ]]; then
|
||||
echo " Found existing ~/.claude/, creating backup at $BACKUP_DIR"
|
||||
cp -r "$CLAUDE_DIR" "$BACKUP_DIR"
|
||||
echo -e "${GREEN} Backup created successfully${NC}"
|
||||
else
|
||||
echo " No existing ~/.claude/ found, no backup needed"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# PRE-CHECKS
|
||||
# ============================================================================
|
||||
echo -e "${YELLOW}===== PRE-CHECKS =====${NC}"
|
||||
|
||||
test_case "CCS executable exists" "ccs script found at $CCS_PATH" bash -c "
|
||||
[[ -f '$CCS_PATH' ]]
|
||||
"
|
||||
|
||||
test_case "CCS executable is executable" "ccs has execute permissions" bash -c "
|
||||
[[ -x '$CCS_PATH' ]]
|
||||
"
|
||||
|
||||
test_case "Source .claude directory exists" ".claude/ in CCS repo" bash -c "
|
||||
[[ -d '$CCS_ROOT/.claude' ]]
|
||||
"
|
||||
|
||||
test_case "Source commands exist" "ccs.md command file exists" bash -c "
|
||||
[[ -f '$CCS_ROOT/.claude/commands/ccs.md' ]]
|
||||
"
|
||||
|
||||
test_case "Source skills exist" "ccs-delegation skill directory exists" bash -c "
|
||||
[[ -d '$CCS_ROOT/.claude/skills/ccs-delegation' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 1: FRESH INSTALLATION (NO ~/.claude/)
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 1: FRESH INSTALLATION =====${NC}"
|
||||
|
||||
# Clean any existing test directory
|
||||
rm -rf "$TEST_HOME"
|
||||
mkdir -p "$TEST_HOME"
|
||||
|
||||
test_case "Fresh install: Command executes without error" "Exit code 0" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --install > /tmp/ccs-install-output.txt 2>&1
|
||||
"
|
||||
|
||||
test_case "Fresh install: Commands directory created" "~/.claude/commands/ exists" bash -c "
|
||||
[[ -d '$TEST_CLAUDE_DIR/commands' ]]
|
||||
"
|
||||
|
||||
test_case "Fresh install: Skills directory created" "~/.claude/skills/ exists" bash -c "
|
||||
[[ -d '$TEST_CLAUDE_DIR/skills' ]]
|
||||
"
|
||||
|
||||
test_case "Fresh install: ccs.md command installed" "ccs.md file exists in commands/" bash -c "
|
||||
[[ -f '$TEST_CLAUDE_DIR/commands/ccs.md' ]]
|
||||
"
|
||||
|
||||
test_case "Fresh install: ccs-delegation skill installed" "ccs-delegation/ exists in skills/" bash -c "
|
||||
[[ -d '$TEST_CLAUDE_DIR/skills/ccs-delegation' ]]
|
||||
"
|
||||
|
||||
test_case "Fresh install: SKILL.md exists" "SKILL.md in ccs-delegation/" bash -c "
|
||||
[[ -f '$TEST_CLAUDE_DIR/skills/ccs-delegation/SKILL.md' ]]
|
||||
"
|
||||
|
||||
test_case "Fresh install: references directory exists" "references/ subdirectory present" bash -c "
|
||||
[[ -d '$TEST_CLAUDE_DIR/skills/ccs-delegation/references' ]]
|
||||
"
|
||||
|
||||
test_case "Fresh install: delegation-patterns.md exists" "Pattern reference file present" bash -c "
|
||||
[[ -f '$TEST_CLAUDE_DIR/skills/ccs-delegation/references/delegation-patterns.md' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 2: OUTPUT FORMATTING (BOX-DRAWING CHARACTERS)
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 2: OUTPUT FORMATTING =====${NC}"
|
||||
|
||||
# Clean for fresh test
|
||||
rm -rf "$TEST_HOME"
|
||||
mkdir -p "$TEST_HOME"
|
||||
|
||||
test_case "Output: Contains box-drawing header" "Output has ┌─" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ ┌─ ]]
|
||||
"
|
||||
|
||||
test_case "Output: Contains box-drawing footer" "Output has └─" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ └─ ]]
|
||||
"
|
||||
|
||||
test_case "Output: Contains pipe for indentation" "Output has │" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ │ ]]
|
||||
"
|
||||
|
||||
test_case "Output: Contains checkmark indicator" "Output has ✓" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ ✓ ]]
|
||||
"
|
||||
|
||||
test_case "Output: Shows source directory" "Output includes source path" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ Source: ]]
|
||||
"
|
||||
|
||||
test_case "Output: Shows target directory" "Output includes target path" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ Target: ]]
|
||||
"
|
||||
|
||||
test_case "Output: Shows installation complete message" "Success message present" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ 'Installation complete' ]]
|
||||
"
|
||||
|
||||
test_case "Output: Shows installed count" "Displays number of installed items" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ 'Installed:' ]]
|
||||
"
|
||||
|
||||
test_case "Output: NO emoji characters used" "Output uses only box-drawing and symbols" bash -c "
|
||||
# Check for actual emoji characters (not box-drawing or symbols like ✓ ℹ ✗)
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
! [[ \$output =~ [🚀📋🎯🎉] ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 3: IDEMPOTENCY (MULTIPLE RUNS)
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 3: IDEMPOTENCY =====${NC}"
|
||||
|
||||
# Start fresh
|
||||
rm -rf "$TEST_HOME"
|
||||
mkdir -p "$TEST_HOME"
|
||||
HOME="$TEST_HOME" "$CCS_PATH" --install > /dev/null 2>&1
|
||||
|
||||
test_case "Idempotent: Second run succeeds" "Second --install doesn't error" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --install > /tmp/ccs-install-second.txt 2>&1
|
||||
"
|
||||
|
||||
test_case "Idempotent: Shows skip messages" "Output contains 'Skipping existing'" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ 'Skipping existing' ]]
|
||||
"
|
||||
|
||||
test_case "Idempotent: Uses info indicator ℹ" "Skip messages have ℹ indicator" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ ℹ ]]
|
||||
"
|
||||
|
||||
test_case "Idempotent: Skipped count shown" "Displays number of skipped items" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ 'Skipped:' ]]
|
||||
"
|
||||
|
||||
test_case "Idempotent: Files remain unchanged" "Original files not modified" bash -c "
|
||||
# Get modification time before second install
|
||||
mtime1=\$(stat -c %Y '$TEST_CLAUDE_DIR/commands/ccs.md' 2>/dev/null || stat -f %m '$TEST_CLAUDE_DIR/commands/ccs.md')
|
||||
sleep 1
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --install > /dev/null 2>&1
|
||||
mtime2=\$(stat -c %Y '$TEST_CLAUDE_DIR/commands/ccs.md' 2>/dev/null || stat -f %m '$TEST_CLAUDE_DIR/commands/ccs.md')
|
||||
[[ \$mtime1 == \$mtime2 ]]
|
||||
"
|
||||
|
||||
test_case "Idempotent: Third run still safe" "Multiple runs are safe" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --install > /dev/null 2>&1
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --install > /dev/null 2>&1
|
||||
[[ -f '$TEST_CLAUDE_DIR/commands/ccs.md' ]] && [[ -d '$TEST_CLAUDE_DIR/skills/ccs-delegation' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 4: CONFLICT HANDLING (EXISTING FILES)
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 4: CONFLICT HANDLING =====${NC}"
|
||||
|
||||
# Create existing files with different content
|
||||
rm -rf "$TEST_CLAUDE_DIR"
|
||||
mkdir -p "$TEST_CLAUDE_DIR/commands"
|
||||
mkdir -p "$TEST_CLAUDE_DIR/skills/ccs-delegation"
|
||||
echo "EXISTING COMMAND CONTENT" > "$TEST_CLAUDE_DIR/commands/ccs.md"
|
||||
echo "EXISTING SKILL CONTENT" > "$TEST_CLAUDE_DIR/skills/ccs-delegation/SKILL.md"
|
||||
|
||||
test_case "Conflict: Skips existing command file" "Doesn't overwrite ccs.md" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --install > /dev/null 2>&1
|
||||
content=\$(cat '$TEST_CLAUDE_DIR/commands/ccs.md')
|
||||
[[ \$content == 'EXISTING COMMAND CONTENT' ]]
|
||||
"
|
||||
|
||||
test_case "Conflict: Skips existing skill directory" "Doesn't overwrite skill" bash -c "
|
||||
content=\$(cat '$TEST_CLAUDE_DIR/skills/ccs-delegation/SKILL.md')
|
||||
[[ \$content == 'EXISTING SKILL CONTENT' ]]
|
||||
"
|
||||
|
||||
test_case "Conflict: Output shows skip message" "User informed about skips" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1)
|
||||
[[ \$output =~ 'Skipping existing command: ccs.md' ]]
|
||||
"
|
||||
|
||||
test_case "Conflict: No data loss" "Original files preserved" bash -c "
|
||||
[[ -f '$TEST_CLAUDE_DIR/commands/ccs.md' ]] &&
|
||||
grep -q 'EXISTING COMMAND CONTENT' '$TEST_CLAUDE_DIR/commands/ccs.md'
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 5: FILE INTEGRITY
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 5: FILE INTEGRITY =====${NC}"
|
||||
|
||||
# Fresh install for integrity checks
|
||||
rm -rf "$TEST_HOME"
|
||||
mkdir -p "$TEST_HOME"
|
||||
HOME="$TEST_HOME" "$CCS_PATH" --install > /dev/null 2>&1
|
||||
|
||||
test_case "Integrity: Command file not empty" "ccs.md has content" bash -c "
|
||||
[[ -s '$TEST_CLAUDE_DIR/commands/ccs.md' ]]
|
||||
"
|
||||
|
||||
test_case "Integrity: Skill file not empty" "SKILL.md has content" bash -c "
|
||||
[[ -s '$TEST_CLAUDE_DIR/skills/ccs-delegation/SKILL.md' ]]
|
||||
"
|
||||
|
||||
test_case "Integrity: Command file matches source" "ccs.md content identical" bash -c "
|
||||
diff -q '$CCS_ROOT/.claude/commands/ccs.md' '$TEST_CLAUDE_DIR/commands/ccs.md'
|
||||
"
|
||||
|
||||
test_case "Integrity: Skill file matches source" "SKILL.md content identical" bash -c "
|
||||
diff -q '$CCS_ROOT/.claude/skills/ccs-delegation/SKILL.md' '$TEST_CLAUDE_DIR/skills/ccs-delegation/SKILL.md'
|
||||
"
|
||||
|
||||
test_case "Integrity: Reference file matches source" "delegation-patterns.md identical" bash -c "
|
||||
diff -q '$CCS_ROOT/.claude/skills/ccs-delegation/references/delegation-patterns.md' \
|
||||
'$TEST_CLAUDE_DIR/skills/ccs-delegation/references/delegation-patterns.md'
|
||||
"
|
||||
|
||||
test_case "Integrity: Directory structure preserved" "All subdirectories present" bash -c "
|
||||
[[ -d '$TEST_CLAUDE_DIR/skills/ccs-delegation/references' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 6: ERROR HANDLING
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 6: ERROR HANDLING =====${NC}"
|
||||
|
||||
test_case "Error: Missing source directory handled" "Graceful error when source missing" bash -c "
|
||||
# Temporarily move .claude directory
|
||||
mv '$CCS_ROOT/.claude' '$CCS_ROOT/.claude.backup'
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1 || true)
|
||||
mv '$CCS_ROOT/.claude.backup' '$CCS_ROOT/.claude'
|
||||
[[ \$output =~ 'Error: Source directory not found' ]]
|
||||
"
|
||||
|
||||
test_case "Error: Shows helpful error message" "Error message explains the issue" bash -c "
|
||||
mv '$CCS_ROOT/.claude' '$CCS_ROOT/.claude.backup'
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1 || true)
|
||||
mv '$CCS_ROOT/.claude.backup' '$CCS_ROOT/.claude'
|
||||
[[ \$output =~ 'CCS repository directory' ]]
|
||||
"
|
||||
|
||||
test_case "Error: Uses error indicator ✗" "Error messages have ✗ indicator" bash -c "
|
||||
mv '$CCS_ROOT/.claude' '$CCS_ROOT/.claude.backup'
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --install 2>&1 || true)
|
||||
mv '$CCS_ROOT/.claude.backup' '$CCS_ROOT/.claude'
|
||||
[[ \$output =~ ✗ ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 7: PERMISSIONS AND OWNERSHIP
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 7: PERMISSIONS AND OWNERSHIP =====${NC}"
|
||||
|
||||
rm -rf "$TEST_CLAUDE_DIR"
|
||||
HOME=$(dirname "$TEST_CLAUDE_DIR") "$CCS_PATH" --install > /dev/null 2>&1
|
||||
|
||||
test_case "Permissions: Command file is readable" "ccs.md has read permissions" bash -c "
|
||||
[[ -r '$TEST_CLAUDE_DIR/commands/ccs.md' ]]
|
||||
"
|
||||
|
||||
test_case "Permissions: Skill file is readable" "SKILL.md has read permissions" bash -c "
|
||||
[[ -r '$TEST_CLAUDE_DIR/skills/ccs-delegation/SKILL.md' ]]
|
||||
"
|
||||
|
||||
test_case "Permissions: Directories are accessible" "Can list directory contents" bash -c "
|
||||
ls '$TEST_CLAUDE_DIR/commands' > /dev/null 2>&1 &&
|
||||
ls '$TEST_CLAUDE_DIR/skills' > /dev/null 2>&1
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 8: INTEGRATION WITH CCS
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}===== SECTION 8: INTEGRATION WITH CCS =====${NC}"
|
||||
|
||||
test_case "Integration: --install flag recognized" "--install doesn't show 'Profile not found'" bash -c "
|
||||
output=\$('$CCS_PATH' --install 2>&1 || true)
|
||||
! [[ \$output =~ 'Profile.*--install.*not found' ]]
|
||||
"
|
||||
|
||||
test_case "Integration: --version still works after --install" "Version command functional" bash -c "
|
||||
output=\$('$CCS_PATH' --version 2>&1)
|
||||
[[ \$output =~ 'CCS' ]]
|
||||
"
|
||||
|
||||
test_case "Integration: --help still works after --install" "Help command functional" bash -c "
|
||||
output=\$('$CCS_PATH' --help 2>&1)
|
||||
[[ \$output =~ 'Usage' ]] || [[ \$output =~ 'Claude' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# FINAL RESULTS
|
||||
# ============================================================================
|
||||
echo ""
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
echo -e "${YELLOW}TEST RESULTS SUMMARY${NC}"
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
echo ""
|
||||
echo -e "${CYAN}Total Tests: $TOTAL_TESTS${NC}"
|
||||
echo -e "${GREEN}Passed: $PASS_COUNT${NC}"
|
||||
|
||||
if [[ $FAIL_COUNT -eq 0 ]]; then
|
||||
echo -e "${GREEN}Failed: $FAIL_COUNT${NC}"
|
||||
else
|
||||
echo -e "${RED}Failed: $FAIL_COUNT${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
SUCCESS_RATE=$(awk "BEGIN {printf \"%.2f\", ($PASS_COUNT / $TOTAL_TESTS) * 100}")
|
||||
|
||||
if awk "BEGIN {exit !($SUCCESS_RATE >= 90)}"; then
|
||||
echo -e "${GREEN}Success Rate: $SUCCESS_RATE%${NC}"
|
||||
elif awk "BEGIN {exit !($SUCCESS_RATE >= 70)}"; then
|
||||
echo -e "${YELLOW}Success Rate: $SUCCESS_RATE%${NC}"
|
||||
else
|
||||
echo -e "${RED}Success Rate: $SUCCESS_RATE%${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
if [[ $FAIL_COUNT -eq 0 ]]; then
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}ALL TESTS PASSED!${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo ""
|
||||
echo -e "${GREEN}--install functionality is production ready!${NC}"
|
||||
exit 0
|
||||
else
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
echo -e "${YELLOW}SOME TESTS FAILED${NC}"
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Review failed tests above for details${NC}"
|
||||
exit 1
|
||||
fi
|
||||
Executable
+310
@@ -0,0 +1,310 @@
|
||||
#!/usr/bin/env bash
|
||||
# CCS --uninstall Functionality Testing (Linux/macOS)
|
||||
# Comprehensive tests for the --uninstall command
|
||||
|
||||
set +e # Don't exit on errors, we're testing
|
||||
PASS_COUNT=0
|
||||
FAIL_COUNT=0
|
||||
TOTAL_TESTS=0
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
GRAY='\033[0;37m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Get script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
CCS_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
CCS_PATH="$CCS_ROOT/ccs"
|
||||
|
||||
# Backup/restore paths
|
||||
CLAUDE_DIR="$HOME/.claude"
|
||||
BACKUP_DIR="/tmp/ccs-test-backup-$(date +%s)"
|
||||
TEST_HOME="/tmp/ccs-test-home"
|
||||
TEST_CLAUDE_DIR="$TEST_HOME/.claude"
|
||||
|
||||
test_case() {
|
||||
local name="$1"
|
||||
local expected="$2"
|
||||
shift 2
|
||||
|
||||
((TOTAL_TESTS++))
|
||||
echo ""
|
||||
echo -e "${CYAN}[$TOTAL_TESTS] $name${NC}"
|
||||
echo -e "${GRAY} Expected: $expected${NC}"
|
||||
|
||||
if "$@"; then
|
||||
echo -e "${GREEN} Result: PASS${NC}"
|
||||
((PASS_COUNT++))
|
||||
return 0
|
||||
else
|
||||
echo -e "${RED} Result: FAIL${NC}"
|
||||
((FAIL_COUNT++))
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup_and_restore() {
|
||||
echo ""
|
||||
echo -e "${YELLOW}Cleaning up and restoring...${NC}"
|
||||
|
||||
# Remove test directory
|
||||
if [[ -d "$TEST_HOME" ]]; then
|
||||
rm -rf "$TEST_HOME"
|
||||
fi
|
||||
|
||||
# Restore backup if it exists
|
||||
if [[ -d "$BACKUP_DIR" ]]; then
|
||||
if [[ -d "$CLAUDE_DIR" ]]; then
|
||||
rm -rf "$CLAUDE_DIR"
|
||||
fi
|
||||
mv "$BACKUP_DIR" "$CLAUDE_DIR"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Cleanup complete.${NC}"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# SETUP
|
||||
# ============================================================================
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "CCS --uninstall Functionality Tests"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# Backup existing .claude directory if it exists
|
||||
if [[ -d "$CLAUDE_DIR" ]]; then
|
||||
echo -e "${YELLOW}Backing up existing .claude directory...${NC}"
|
||||
cp -r "$CLAUDE_DIR" "$BACKUP_DIR"
|
||||
fi
|
||||
|
||||
# Clean any existing test directory
|
||||
if [[ -d "$TEST_HOME" ]]; then
|
||||
rm -rf "$TEST_HOME"
|
||||
fi
|
||||
|
||||
mkdir -p "$TEST_HOME"
|
||||
|
||||
# ============================================================================
|
||||
# TEST SECTION 1: UNINSTALL WHEN NOTHING IS INSTALLED
|
||||
# ============================================================================
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "SECTION 1: UNINSTALL WHEN NOTHING IS INSTALLED"
|
||||
echo "========================================"
|
||||
|
||||
test_case "Empty uninstall: Command executes without error" "Exit code 0" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --uninstall > /tmp/ccs-uninstall-empty.txt 2>&1
|
||||
"
|
||||
|
||||
test_case "Empty uninstall: Output contains 'Nothing to uninstall'" "Appropriate message" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --uninstall 2>&1)
|
||||
[[ \$output =~ 'Nothing to uninstall' ]]
|
||||
"
|
||||
|
||||
test_case "Empty uninstall: Reports 0 items removed" "Zero removed count" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --uninstall 2>&1)
|
||||
[[ \$output =~ 'Removed: 0 items' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SETUP FOR FULL INSTALL/UNINSTALL CYCLE
|
||||
# ============================================================================
|
||||
|
||||
# Install first so we can test uninstall
|
||||
echo ""
|
||||
echo -e "${YELLOW}Setting up for install/uninstall cycle test...${NC}"
|
||||
bash -c "HOME='$TEST_HOME' '$CCS_PATH' --install > /dev/null 2>&1"
|
||||
|
||||
# ============================================================================
|
||||
# TEST SECTION 2: UNINSTALL AFTER INSTALL
|
||||
# ============================================================================
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "SECTION 2: UNINSTALL AFTER INSTALL"
|
||||
echo "========================================"
|
||||
|
||||
test_case "Uninstall: Command executes without error" "Exit code 0" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --uninstall > /tmp/ccs-uninstall-after-install.txt 2>&1
|
||||
"
|
||||
|
||||
test_case "Uninstall: Removes ccs.md command file" "Command file removed" bash -c "
|
||||
[[ ! -f '$TEST_CLAUDE_DIR/commands/ccs.md' ]]
|
||||
"
|
||||
|
||||
test_case "Uninstall: Removes ccs-delegation skill directory" "Skill directory removed" bash -c "
|
||||
[[ ! -d '$TEST_CLAUDE_DIR/skills/ccs-delegation' ]]
|
||||
"
|
||||
|
||||
test_case "Uninstall: Preserves other commands" "Other commands unaffected" bash -c "
|
||||
# Create a dummy command file first
|
||||
mkdir -p '$TEST_CLAUDE_DIR/commands'
|
||||
echo 'test' > '$TEST_CLAUDE_DIR/commands/test.md'
|
||||
# Install CCS, then uninstall
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --install > /dev/null 2>&1
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --uninstall > /dev/null 2>&1
|
||||
# Check that test.md still exists
|
||||
[[ -f '$TEST_CLAUDE_DIR/commands/test.md' ]]
|
||||
"
|
||||
|
||||
test_case "Uninstall: Preserves other skills" "Other skills unaffected" bash -c "
|
||||
# Create a dummy skill directory first
|
||||
mkdir -p '$TEST_CLAUDE_DIR/skills/test-skill'
|
||||
echo 'test' > '$TEST_CLAUDE_DIR/skills/test-skill/SKILL.md'
|
||||
# Install CCS, then uninstall
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --install > /dev/null 2>&1
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --uninstall > /dev/null 2>&1
|
||||
# Check that test-skill still exists
|
||||
[[ -d '$TEST_CLAUDE_DIR/skills/test-skill' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# TEST SECTION 3: IDEMPOTENCY
|
||||
# ============================================================================
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "SECTION 3: IDEMPOTENCY"
|
||||
echo "========================================"
|
||||
|
||||
test_case "Idempotent: Second uninstall succeeds" "Second --uninstall doesn't error" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --uninstall > /dev/null 2>&1
|
||||
exit_code=\$?
|
||||
[[ \$exit_code -eq 0 ]]
|
||||
"
|
||||
|
||||
test_case "Idempotent: Reports nothing to remove on second run" "Reports nothing found" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --uninstall 2>&1)
|
||||
[[ \$output =~ 'not found' ]] || [[ \$output =~ 'Nothing to uninstall' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# TEST SECTION 4: OUTPUT FORMATTING
|
||||
# ============================================================================
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "SECTION 4: OUTPUT FORMATTING"
|
||||
echo "========================================"
|
||||
|
||||
# Set up fresh install for output testing
|
||||
bash -c "HOME='$TEST_HOME' '$CCS_PATH' --install > /dev/null 2>&1"
|
||||
|
||||
test_case "Output: Contains box-drawing header" "Output has ┌─" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --uninstall 2>&1)
|
||||
[[ \$output =~ ┌─ ]]
|
||||
"
|
||||
|
||||
test_case "Output: Contains box-drawing footer" "Output has └─" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --uninstall 2>&1)
|
||||
[[ \$output =~ └─ ]]
|
||||
"
|
||||
|
||||
test_case "Output: Shows removal success message" "Contains '[OK] Uninstall complete!'" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --uninstall 2>&1)
|
||||
echo \"\$output\" | grep -q '\[OK\] Uninstall complete!'
|
||||
"
|
||||
|
||||
test_case "Output: Shows reinstallation instruction" "Contains reinstallation hint" bash -c "
|
||||
output=\$(HOME='$TEST_HOME' '$CCS_PATH' --uninstall 2>&1)
|
||||
[[ \$output =~ 'To reinstall: ccs --install' ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# TEST SECTION 5: INTEGRATION WITH CCS
|
||||
# ============================================================================
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "SECTION 5: INTEGRATION WITH CCS"
|
||||
echo "========================================"
|
||||
|
||||
test_case "Integration: --uninstall executes without profile error" "No profile error on --uninstall" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --uninstall > /dev/null 2>&1
|
||||
exit_code=\$?
|
||||
[[ \$exit_code -eq 0 ]]
|
||||
"
|
||||
|
||||
test_case "Integration: --version still works after uninstall" "Version command exits successfully" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --version > /dev/null 2>&1
|
||||
exit_code=\$?
|
||||
[[ \$exit_code -eq 0 ]]
|
||||
"
|
||||
|
||||
test_case "Integration: --help still works after uninstall" "Help command exits successfully" bash -c "
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --help > /dev/null 2>&1
|
||||
exit_code=\$?
|
||||
[[ \$exit_code -eq 0 ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# TEST SECTION 6: EDGE CASES
|
||||
# ============================================================================
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "SECTION 6: EDGE CASES"
|
||||
echo "========================================"
|
||||
|
||||
test_case "Edge case: Partial install (commands only)" "Handles partial installation" bash -c "
|
||||
# Create only command file
|
||||
mkdir -p '$TEST_CLAUDE_DIR/commands'
|
||||
echo 'test' > '$TEST_CLAUDE_DIR/commands/ccs.md'
|
||||
# Uninstall should handle this gracefully
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --uninstall > /dev/null 2>&1
|
||||
exit_code=\$?
|
||||
[[ \$exit_code -eq 0 ]]
|
||||
"
|
||||
|
||||
test_case "Edge case: Partial install (skills only)" "Handles partial installation" bash -c "
|
||||
# Create only skill directory
|
||||
mkdir -p '$TEST_CLAUDE_DIR/skills/ccs-delegation'
|
||||
echo 'test' > '$TEST_CLAUDE_DIR/skills/ccs-delegation/SKILL.md'
|
||||
# Uninstall should handle this gracefully
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --uninstall > /dev/null 2>&1
|
||||
exit_code=\$?
|
||||
[[ \$exit_code -eq 0 ]]
|
||||
"
|
||||
|
||||
test_case "Edge case: Missing parent directories" "Handles missing .claude directory" bash -c "
|
||||
# Ensure .claude directory doesn't exist
|
||||
rm -rf '$TEST_CLAUDE_DIR'
|
||||
HOME='$TEST_HOME' '$CCS_PATH' --uninstall > /dev/null 2>&1
|
||||
exit_code=\$?
|
||||
[[ \$exit_code -eq 0 ]]
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# SUMMARY
|
||||
# ============================================================================
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
if [[ $FAIL_COUNT -eq 0 ]]; then
|
||||
echo -e "${GREEN}ALL TESTS PASSED!${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}--uninstall functionality is production ready!${NC}"
|
||||
else
|
||||
echo -e "${RED}SOME TESTS FAILED${NC}"
|
||||
echo -e "${RED}========================================${NC}"
|
||||
echo -e "${RED}Review failed tests above for details${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${CYAN}Test Summary:${NC}"
|
||||
echo -e " Total tests: $TOTAL_TESTS"
|
||||
echo -e " ${GREEN}Passed: $PASS_COUNT${NC}"
|
||||
echo -e " ${RED}Failed: $FAIL_COUNT${NC}"
|
||||
echo ""
|
||||
|
||||
# Cleanup
|
||||
cleanup_and_restore
|
||||
|
||||
exit $FAIL_COUNT
|
||||
Reference in new issue
Block a user