Files
claude-code/automation/test-scripts.sh
OpenCode Test 125bb4904b Add search command, history browser, install script, and systemd timers
- /search command to search across memory, history, and configuration
- history-browser.py for browsing and analyzing session history
- install.sh for first-time setup with directory creation and validation
- daily-maintenance.sh for scheduled backup, cleanup, and validation
- systemd timer units for automated daily maintenance at 6 AM
- Updated shell completions with 11 aliases
- Test suite now covers 19 tests
- Bump version to 1.1.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 18:41:07 -08:00

140 lines
3.7 KiB
Bash
Executable File

#!/bin/bash
# Test automation scripts
# Run: ./test-scripts.sh
set -euo pipefail
CLAUDE_DIR="${HOME}/.claude"
AUTOMATION_DIR="${CLAUDE_DIR}/automation"
SKILLS_DIR="${CLAUDE_DIR}/skills"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
PASS=0
FAIL=0
pass() { echo -e "${GREEN}${NC} $1"; PASS=$((PASS + 1)); }
fail() { echo -e "${RED}${NC} $1"; FAIL=$((FAIL + 1)); }
skip() { echo -e "${YELLOW}${NC} $1 (skipped)"; }
echo "🧪 Testing Claude Code Scripts"
echo ""
# Test 1: validate-setup.sh
echo "=== Automation Scripts ==="
if "${AUTOMATION_DIR}/validate-setup.sh" > /dev/null 2>&1; then
pass "validate-setup.sh runs successfully"
else
fail "validate-setup.sh failed"
fi
# Test 2: quick-status.sh (may fail without kubectl)
# Skip in automated testing - requires live connections
skip "quick-status.sh (requires live connections)"
# Test 3: memory-add.py (test syntax only)
if python3 -m py_compile "${AUTOMATION_DIR}/memory-add.py" 2>/dev/null; then
pass "memory-add.py syntax valid"
else
fail "memory-add.py syntax error"
fi
# Test 4: memory-list.py (test syntax only)
if python3 -m py_compile "${AUTOMATION_DIR}/memory-list.py" 2>/dev/null; then
pass "memory-list.py syntax valid"
else
fail "memory-list.py syntax error"
fi
# Test 5: usage_report.py (test syntax only)
if python3 -m py_compile "${SKILLS_DIR}/usage/scripts/usage_report.py" 2>/dev/null; then
pass "usage_report.py syntax valid"
else
fail "usage_report.py syntax error"
fi
# Test 6: search.py
if python3 -m py_compile "${AUTOMATION_DIR}/search.py" 2>/dev/null; then
pass "search.py syntax valid"
else
fail "search.py syntax error"
fi
# Test 7: history-browser.py
if python3 -m py_compile "${AUTOMATION_DIR}/history-browser.py" 2>/dev/null; then
pass "history-browser.py syntax valid"
else
fail "history-browser.py syntax error"
fi
echo ""
echo "=== Skill Scripts ==="
# Test Gmail scripts (syntax only - need credentials to run)
for script in check_unread.py check_urgent.py search.py; do
if python3 -m py_compile "${SKILLS_DIR}/gmail/scripts/${script}" 2>/dev/null; then
pass "gmail/${script} syntax valid"
else
fail "gmail/${script} syntax error"
fi
done
# Test GCal scripts
for script in agenda.py next_event.py; do
if python3 -m py_compile "${SKILLS_DIR}/gcal/scripts/${script}" 2>/dev/null; then
pass "gcal/${script} syntax valid"
else
fail "gcal/${script} syntax error"
fi
done
# Test bash scripts (syntax check with bash -n)
echo ""
echo "=== Bash Scripts ==="
for script in quick-status.sh health-check.sh; do
script_path=$(find "${CLAUDE_DIR}" -name "${script}" -type f | head -1)
if [[ -n "${script_path}" ]]; then
if bash -n "${script_path}" 2>/dev/null; then
pass "${script} syntax valid"
else
fail "${script} syntax error"
fi
fi
done
# Test k8s quick-status
if bash -n "${SKILLS_DIR}/k8s-quick-status/scripts/quick-status.sh" 2>/dev/null; then
pass "k8s/quick-status.sh syntax valid"
else
fail "k8s/quick-status.sh syntax error"
fi
# Test automation bash scripts
for script in install.sh daily-maintenance.sh backup.sh restore.sh clean.sh; do
if [[ -f "${AUTOMATION_DIR}/${script}" ]]; then
if bash -n "${AUTOMATION_DIR}/${script}" 2>/dev/null; then
pass "${script} syntax valid"
else
fail "${script} syntax error"
fi
fi
done
echo ""
echo "=== Summary ==="
echo -e "Passed: ${GREEN}${PASS}${NC}"
echo -e "Failed: ${RED}${FAIL}${NC}"
if [[ ${FAIL} -eq 0 ]]; then
echo -e "\n${GREEN}All tests passed!${NC}"
exit 0
else
echo -e "\n${RED}${FAIL} test(s) failed${NC}"
exit 1
fi