#!/bin/bash
set -e
echo "🧪 Claude Infinite Context - Basic Verification Tests"
echo "======================================================"
echo
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Test counter
TESTS_RUN=0
TESTS_PASSED=0
run_test() {
local name=$1
local command=$2
local expected=$3
TESTS_RUN=$((TESTS_RUN + 1))
echo -n "Test $TESTS_RUN: $name... "
if output=$(eval "$command" 2>&1); then
if [[ -z "$expected" ]] || echo "$output" | grep -q "$expected"; then
echo -e "${GREEN}✓ PASS${NC}"
TESTS_PASSED=$((TESTS_PASSED + 1))
return 0
else
echo -e "${RED}✗ FAIL${NC}"
echo " Expected: $expected"
echo " Got: $output"
return 1
fi
else
echo -e "${RED}✗ FAIL${NC}"
echo " Command failed: $output"
return 1
fi
}
echo "1️⃣ Prerequisites"
echo "----------------"
# Test Redis
run_test "Redis is running" "redis-cli ping" "PONG"
# Test Redis JSON support
run_test "Redis JSON module loaded" "redis-cli JSON.SET test-key $ '{\"test\":1}' && redis-cli JSON.GET test-key && redis-cli DEL test-key" "test"
# Test Node.js
run_test "Node.js version" "node --version" "v"
# Test build exists
run_test "Build exists" "test -f dist/index.js && echo 'exists'" "exists"
echo
echo "2️⃣ MCP Server"
echo "-------------"
# Test server starts
run_test "Server starts" "echo '{\"jsonrpc\":\"2.0\",\"method\":\"tools/list\",\"id\":1}' | timeout 5 node dist/index.js 2>&1" "tools"
# Test all 4 tools exist
run_test "Checkpoint tool exists" "echo '{\"jsonrpc\":\"2.0\",\"method\":\"tools/list\",\"id\":1}' | timeout 5 node dist/index.js 2>&1" "checkpoint"
run_test "Resume tool exists" "echo '{\"jsonrpc\":\"2.0\",\"method\":\"tools/list\",\"id\":1}' | timeout 5 node dist/index.js 2>&1" "resume"
run_test "Rollback tool exists" "echo '{\"jsonrpc\":\"2.0\",\"method\":\"tools/list\",\"id\":1}' | timeout 5 node dist/index.js 2>&1" "rollback"
run_test "Status tool exists" "echo '{\"jsonrpc\":\"2.0\",\"method\":\"tools/list\",\"id\":1}' | timeout 5 node dist/index.js 2>&1" "status"
echo
echo "3️⃣ File Structure"
echo "-----------------"
# Test source files
run_test "Schema types exist" "test -f src/types/schema.ts && echo 'exists'" "exists"
run_test "RedisClient exists" "test -f src/core/RedisClient.ts && echo 'exists'" "exists"
run_test "SummaryMerger exists" "test -f src/core/SummaryMerger.ts && echo 'exists'" "exists"
run_test "ProjectBrain exists" "test -f src/core/ProjectBrain.ts && echo 'exists'" "exists"
run_test "Session manager exists" "test -f src/utils/sessionId.ts && echo 'exists'" "exists"
echo
echo "4️⃣ Configuration"
echo "----------------"
# Test config files
run_test "package.json exists" "test -f package.json && echo 'exists'" "exists"
run_test "tsconfig.json exists" "test -f tsconfig.json && echo 'exists'" "exists"
run_test ".env.example exists" "test -f .env.example && echo 'exists'" "exists"
# Test dependencies
run_test "Dependencies installed" "test -d node_modules && echo 'exists'" "exists"
echo
echo "======================================================"
echo -e "Results: ${GREEN}$TESTS_PASSED${NC}/${TESTS_RUN} tests passed"
if [ $TESTS_PASSED -eq $TESTS_RUN ]; then
echo -e "${GREEN}✅ All tests passed! System is ready.${NC}"
echo
echo "Next steps:"
echo "1. Add your API key to .env file"
echo "2. Add to Claude Code config: ~/.config/claude-code/config.json"
echo "3. See README.md ## Testing section for usage examples"
exit 0
else
echo -e "${RED}❌ Some tests failed. Check the output above.${NC}"
exit 1
fi