|
1 | | -#! /usr/bin/env bash |
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Development test setup script for backend project |
| 4 | +# This script starts necessary services for testing |
| 5 | + |
2 | 6 | set -e |
3 | | -set -x |
4 | 7 |
|
5 | | -python app/tests_pre_start.py |
| 8 | +echo "🚀 Starting development environment for testing..." |
| 9 | + |
| 10 | +# Check if virtual environment is active |
| 11 | +if [[ "$VIRTUAL_ENV" == "" ]]; then |
| 12 | + echo "❌ ERROR: Virtual environment not activated!" |
| 13 | + echo "Please run: source .venv/bin/activate" |
| 14 | + exit 1 |
| 15 | +fi |
| 16 | + |
| 17 | +# Check if uv is installed |
| 18 | +if ! command -v uv &> /dev/null; then |
| 19 | + echo "❌ ERROR: uv is not installed!" |
| 20 | + echo "Please install uv: pip install uv" |
| 21 | + exit 1 |
| 22 | +fi |
| 23 | + |
| 24 | +echo "✅ Environment checks passed" |
| 25 | + |
| 26 | +# Sync dependencies if needed |
| 27 | +echo "📦 Syncing dependencies..." |
| 28 | +uv sync |
| 29 | + |
| 30 | +# Validate critical versions |
| 31 | +echo "🔍 Validating critical dependency versions..." |
| 32 | + |
| 33 | +# Check httpx version |
| 34 | +HTTPX_VERSION=$(uv run python -c "import httpx; print(httpx.__version__)" 2>/dev/null || echo "not installed") |
| 35 | +if [[ "$HTTPX_VERSION" == "0.24.1" ]]; then |
| 36 | + echo "✅ httpx version: $HTTPX_VERSION (correct)" |
| 37 | +else |
| 38 | + echo "❌ httpx version: $HTTPX_VERSION (expected: 0.24.1)" |
| 39 | + echo "Please run: uv sync" |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | + |
| 43 | +# Check fastapi version |
| 44 | +FASTAPI_VERSION=$(uv run python -c "import fastapi; print(fastapi.__version__)" 2>/dev/null || echo "not installed") |
| 45 | +if [[ "$FASTAPI_VERSION" == "0.109.2" ]]; then |
| 46 | + echo "✅ fastapi version: $FASTAPI_VERSION (correct)" |
| 47 | +else |
| 48 | + echo "❌ fastapi version: $FASTAPI_VERSION (expected: 0.109.2)" |
| 49 | + echo "Please run: uv sync" |
| 50 | + exit 1 |
| 51 | +fi |
| 52 | + |
| 53 | +# Run pre-start script if it exists |
| 54 | +if [[ -f "app/tests_pre_start.py" ]]; then |
| 55 | + echo "🔧 Running test pre-start script..." |
| 56 | + python app/tests_pre_start.py |
| 57 | +fi |
6 | 58 |
|
7 | | -bash scripts/test.sh "$@" |
| 59 | +echo "✅ All validations passed!" |
| 60 | +echo "🎯 Development environment ready for testing!" |
| 61 | +echo "" |
| 62 | +echo "Usage:" |
| 63 | +echo " ./scripts/run-tests.sh # Run all tests" |
| 64 | +echo " ./scripts/run-tests.sh test_file.py # Run specific test" |
| 65 | +echo " ./scripts/run-tests.sh -v # Verbose output" |
0 commit comments