79 lines
1.9 KiB
Bash
79 lines
1.9 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
# Script to run all test suites for veza-backend-api
|
||
|
|
# Usage: ./scripts/test_all.sh [unit|integration|race|all]
|
||
|
|
|
||
|
|
set -e
|
||
|
|
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||
|
|
|
||
|
|
cd "$PROJECT_ROOT"
|
||
|
|
|
||
|
|
# Colors for output
|
||
|
|
RED='\033[0;31m'
|
||
|
|
GREEN='\033[0;32m'
|
||
|
|
YELLOW='\033[1;33m'
|
||
|
|
NC='\033[0m' # No Color
|
||
|
|
|
||
|
|
# Function to print status
|
||
|
|
print_status() {
|
||
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
||
|
|
}
|
||
|
|
|
||
|
|
print_error() {
|
||
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
||
|
|
}
|
||
|
|
|
||
|
|
print_warning() {
|
||
|
|
echo -e "${YELLOW}[WARN]${NC} $1"
|
||
|
|
}
|
||
|
|
|
||
|
|
# Parse arguments
|
||
|
|
MODE="${1:-all}"
|
||
|
|
|
||
|
|
case "$MODE" in
|
||
|
|
unit)
|
||
|
|
print_status "Running unit tests..."
|
||
|
|
go test ./... -count=1 -v
|
||
|
|
;;
|
||
|
|
integration)
|
||
|
|
print_status "Running integration tests..."
|
||
|
|
go test ./... -tags=integration -count=1 -v
|
||
|
|
;;
|
||
|
|
race)
|
||
|
|
print_status "Running race detector tests..."
|
||
|
|
go test ./... -race -count=1 -v
|
||
|
|
;;
|
||
|
|
all)
|
||
|
|
print_status "Running all test suites..."
|
||
|
|
|
||
|
|
print_status "1/3: Unit tests"
|
||
|
|
if go test ./... -count=1; then
|
||
|
|
print_status "✓ Unit tests passed"
|
||
|
|
else
|
||
|
|
print_error "✗ Unit tests failed"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
print_status "2/3: Integration tests"
|
||
|
|
if go test ./... -tags=integration -count=1; then
|
||
|
|
print_status "✓ Integration tests passed"
|
||
|
|
else
|
||
|
|
print_warning "⚠ Integration tests failed (may require external services)"
|
||
|
|
fi
|
||
|
|
|
||
|
|
print_status "3/3: Race detector tests"
|
||
|
|
if go test ./... -race -count=1; then
|
||
|
|
print_status "✓ Race detector tests passed"
|
||
|
|
else
|
||
|
|
print_warning "⚠ Race detector tests failed"
|
||
|
|
fi
|
||
|
|
|
||
|
|
print_status "All test suites completed"
|
||
|
|
;;
|
||
|
|
*)
|
||
|
|
echo "Usage: $0 [unit|integration|race|all]"
|
||
|
|
exit 1
|
||
|
|
;;
|
||
|
|
esac
|