Files
chat/tests/test_user_api.sh
Andrew K. Choi 003950dce6
Some checks reported errors
continuous-integration/drone Build encountered an error
CI/CD pipeline
2025-09-25 08:42:22 +09:00

53 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
echo "🚀 Starting User Service and Testing API"
# Activate virtual environment
source .venv/bin/activate
# Set PYTHONPATH
export PYTHONPATH="${PWD}:${PYTHONPATH}"
# Start user service in background
cd services/user_service
python -m uvicorn main:app --host 0.0.0.0 --port 8001 &
USER_SERVICE_PID=$!
echo "⏳ Waiting for service to start..."
sleep 5
# Go back to project root
cd ../..
# Test registration
echo "🧪 Testing user registration..."
RESPONSE=$(curl -s -X POST "http://localhost:8001/api/v1/register" \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "testpassword123",
"first_name": "Test",
"last_name": "User",
"phone": "+1234567890"
}')
echo "📝 Registration response:"
echo "$RESPONSE" | jq . 2>/dev/null || echo "$RESPONSE"
# Test login
echo -e "\n🧪 Testing user login..."
LOGIN_RESPONSE=$(curl -s -X POST "http://localhost:8001/api/v1/login" \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "testpassword123"
}')
echo "📝 Login response:"
echo "$LOGIN_RESPONSE" | jq . 2>/dev/null || echo "$LOGIN_RESPONSE"
# Stop the service
echo -e "\n🛑 Stopping service..."
kill $USER_SERVICE_PID
echo "✅ Test completed!"