mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
The download_file_via_url method was using requests.get() directly without the Authorization header, causing all downloads to fail with 401/403 errors even though the job completed successfully. Now uses self.session.get() which includes the auth token from headers. Bump version to 0.75.51
112 lines
2.5 KiB
Bash
Executable File
112 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Run CLI + Backend integration tests
|
|
#
|
|
# This script:
|
|
# 1. Starts emulators
|
|
# 2. Starts local backend
|
|
# 3. Runs integration tests
|
|
# 4. Cleans up
|
|
#
|
|
# Usage:
|
|
# ./scripts/run-cli-integration-tests.sh
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
echo "🧪 Running CLI + Backend Integration Tests"
|
|
echo "==========================================="
|
|
echo ""
|
|
|
|
# Cleanup function
|
|
cleanup() {
|
|
echo ""
|
|
echo "Cleaning up..."
|
|
|
|
# Kill backend if running
|
|
if [ ! -z "$BACKEND_PID" ]; then
|
|
kill $BACKEND_PID 2>/dev/null || true
|
|
echo " Stopped backend (PID $BACKEND_PID)"
|
|
fi
|
|
|
|
# Stop emulators
|
|
"$SCRIPT_DIR/stop-emulators.sh" 2>/dev/null || true
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
# Step 1: Start emulators
|
|
echo "Step 1/4: Starting GCP emulators..."
|
|
"$SCRIPT_DIR/start-emulators.sh"
|
|
echo ""
|
|
|
|
# Step 2: Set environment
|
|
echo "Step 2/4: Setting environment..."
|
|
export FIRESTORE_EMULATOR_HOST="127.0.0.1:8080"
|
|
export STORAGE_EMULATOR_HOST="http://127.0.0.1:4443"
|
|
export GOOGLE_CLOUD_PROJECT="test-project"
|
|
export GCS_BUCKET_NAME="test-bucket"
|
|
export FIRESTORE_COLLECTION="jobs"
|
|
export ENVIRONMENT="test"
|
|
export ADMIN_TOKENS="test-admin-token"
|
|
|
|
# Disable external services for tests
|
|
export FLACFETCH_API_URL=""
|
|
export AUDIO_SEPARATOR_API_URL=""
|
|
export AUDIOSHAKE_API_TOKEN=""
|
|
export GENIUS_API_TOKEN=""
|
|
export SPOTIFY_COOKIE=""
|
|
|
|
echo " Environment configured for local testing"
|
|
echo ""
|
|
|
|
# Step 3: Start backend
|
|
echo "Step 3/4: Starting local backend..."
|
|
cd "$PROJECT_ROOT"
|
|
|
|
if command -v poetry &> /dev/null; then
|
|
poetry run uvicorn backend.main:app --host 127.0.0.1 --port 8000 &
|
|
else
|
|
python -m uvicorn backend.main:app --host 127.0.0.1 --port 8000 &
|
|
fi
|
|
BACKEND_PID=$!
|
|
|
|
# Wait for backend
|
|
echo " Waiting for backend..."
|
|
for i in {1..30}; do
|
|
if curl -s http://localhost:8000/api/health > /dev/null 2>&1; then
|
|
echo " Backend ready!"
|
|
break
|
|
fi
|
|
if [ $i -eq 30 ]; then
|
|
echo " ❌ Backend failed to start"
|
|
exit 1
|
|
fi
|
|
sleep 1
|
|
done
|
|
echo ""
|
|
|
|
# Step 4: Run tests
|
|
echo "Step 4/4: Running integration tests..."
|
|
echo ""
|
|
|
|
cd "$PROJECT_ROOT"
|
|
|
|
if command -v poetry &> /dev/null; then
|
|
PYTEST_CMD="poetry run pytest"
|
|
else
|
|
PYTEST_CMD="pytest"
|
|
fi
|
|
|
|
if $PYTEST_CMD tests/integration/test_cli_backend_integration.py -v --tb=short; then
|
|
echo ""
|
|
echo "✅ All CLI + Backend integration tests passed!"
|
|
exit 0
|
|
else
|
|
echo ""
|
|
echo "❌ Some integration tests failed"
|
|
exit 1
|
|
fi
|
|
|