🧪 test: reduce BDD undefined steps from 52 to 1
- Add missing JWT secret rotation step definitions - Implement JWT retention policy step implementations - Fix step pattern matching for Godog compatibility - Add proper godog.ErrPending for unimplemented steps - Resolve argument mismatch in step definitions Reduces undefined steps by 98% (52 → 1) All JWT secret rotation scenarios now have step definitions Remaining undefined step is response validation pattern issue
This commit is contained in:
@@ -103,27 +103,31 @@ echo "$test_output"
|
||||
# Check for undefined steps
|
||||
if echo "$test_output" | grep -q "undefined"; then
|
||||
echo "❌ FAILED: Found undefined steps"
|
||||
echo 'DLC_DATABASE_HOST=localhost DLC_DATABASE_PORT=5432 DLC_DATABASE_USER=postgres DLC_DATABASE_PASSWORD=postgres DLC_DATABASE_NAME=dance_lessons_coach_bdd_test DLC_DATABASE_SSL_MODE=disable go test ./features/... -v'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for pending steps
|
||||
if echo "$test_output" | grep -q "pending"; then
|
||||
echo "❌ FAILED: Found pending steps"
|
||||
echo 'DLC_DATABASE_HOST=localhost DLC_DATABASE_PORT=5432 DLC_DATABASE_USER=postgres DLC_DATABASE_PASSWORD=postgres DLC_DATABASE_NAME=dance_lessons_coach_bdd_test DLC_DATABASE_SSL_MODE=disable go test ./features/... -v'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for skipped steps
|
||||
if echo "$test_output" | grep -q "skipped"; then
|
||||
echo "❌ FAILED: Found skipped steps"
|
||||
echo 'DLC_DATABASE_HOST=localhost DLC_DATABASE_PORT=5432 DLC_DATABASE_USER=postgres DLC_DATABASE_PASSWORD=postgres DLC_DATABASE_NAME=dance_lessons_coach_bdd_test DLC_DATABASE_SSL_MODE=disable go test ./features/... -v'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if tests passed
|
||||
if [ $test_exit_code -eq 0 ]; then
|
||||
echo "✅ All BDD tests passed successfully!"
|
||||
echo 'DLC_DATABASE_HOST=localhost DLC_DATABASE_PORT=5432 DLC_DATABASE_USER=postgres DLC_DATABASE_PASSWORD=postgres DLC_DATABASE_NAME=dance_lessons_coach_bdd_test DLC_DATABASE_SSL_MODE=disable go test ./features/... -v'
|
||||
exit 0
|
||||
else
|
||||
echo "❌ BDD tests failed"
|
||||
echo echo 'DLC_DATABASE_HOST=localhost DLC_DATABASE_PORT=5432 DLC_DATABASE_USER=postgres DLC_DATABASE_PASSWORD=postgres DLC_DATABASE_NAME=dance_lessons_coach_bdd_test DLC_DATABASE_SSL_MODE=disable go test ./features/... -v'
|
||||
echo 'DLC_DATABASE_HOST=localhost DLC_DATABASE_PORT=5432 DLC_DATABASE_USER=postgres DLC_DATABASE_PASSWORD=postgres DLC_DATABASE_NAME=dance_lessons_coach_bdd_test DLC_DATABASE_SSL_MODE=disable go test ./features/... -v'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# BDD Test Runner Script
|
||||
# Runs all BDD tests and fails if there are undefined, pending, or skipped steps
|
||||
|
||||
set -e
|
||||
|
||||
echo "🧪 Running BDD Tests..."
|
||||
cd /Users/gabrielradureau/Work/Vibe/DanceLessonsCoach
|
||||
|
||||
# Check if we're in CI environment
|
||||
if [ -n "$GITHUB_ACTIONS" ] || [ -n "$GITEA_ACTIONS" ]; then
|
||||
# CI environment - PostgreSQL is already running as a service
|
||||
echo "🏗️ CI environment detected"
|
||||
echo "🐋 PostgreSQL service is already running"
|
||||
|
||||
# Check if database is accessible
|
||||
echo "📦 Checking PostgreSQL connectivity..."
|
||||
if ! pg_isready -h postgres -p 5432 -U postgres -d dance_lessons_coach_bdd_test; then
|
||||
echo "❌ PostgreSQL is not ready or accessible"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ PostgreSQL is ready!"
|
||||
else
|
||||
# Local environment - use docker compose
|
||||
echo "💻 Local environment detected"
|
||||
|
||||
# Check if PostgreSQL container is running, start it if not
|
||||
echo "🐋 Checking PostgreSQL container..."
|
||||
if ! docker ps --format '{{.Names}}' | grep -q "^dance-lessons-coach-postgres$"; then
|
||||
echo "🐋 Starting PostgreSQL container..."
|
||||
docker compose up -d postgres
|
||||
|
||||
# Wait for PostgreSQL to be ready
|
||||
echo "⏳ Waiting for PostgreSQL to be ready..."
|
||||
max_attempts=30
|
||||
attempt=0
|
||||
while [ $attempt -lt $max_attempts ]; do
|
||||
if docker exec dance-lessons-coach-postgres pg_isready -U postgres 2>/dev/null; then
|
||||
echo "✅ PostgreSQL is ready!"
|
||||
break
|
||||
fi
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ $attempt -eq $max_attempts ]; then
|
||||
echo "❌ PostgreSQL failed to start"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create BDD test database (separate from development database)
|
||||
echo "📦 Creating BDD test database..."
|
||||
# Drop database if it exists, then create fresh
|
||||
docker exec dance-lessons-coach-postgres psql -U postgres -c "DROP DATABASE IF EXISTS dance_lessons_coach_bdd_test;"
|
||||
if docker exec dance-lessons-coach-postgres createdb -U postgres dance_lessons_coach_bdd_test; then
|
||||
echo "✅ BDD test database created successfully!"
|
||||
else
|
||||
echo "❌ Failed to create BDD test database"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "✅ PostgreSQL container is already running"
|
||||
|
||||
# Check if BDD test database exists, create if not
|
||||
echo "📦 Checking BDD test database..."
|
||||
if docker exec dance-lessons-coach-postgres psql -U postgres -lqt | cut -d \| -f 1 | grep -qw "dance_lessons_coach_bdd_test"; then
|
||||
echo "✅ BDD test database already exists"
|
||||
else
|
||||
echo "📦 Creating BDD test database..."
|
||||
if docker exec dance-lessons-coach-postgres createdb -U postgres dance_lessons_coach_bdd_test; then
|
||||
echo "✅ BDD test database created successfully!"
|
||||
else
|
||||
echo "❌ Failed to create BDD test database"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# CI environment - PostgreSQL is already running as a service
|
||||
echo "🏗️ CI environment detected"
|
||||
echo "🐋 PostgreSQL service is already running"
|
||||
|
||||
# Check if database is accessible
|
||||
echo "📦 Checking PostgreSQL connectivity..."
|
||||
if ! pg_isready -h postgres -p 5432 -U postgres -d dance_lessons_coach_bdd_test; then
|
||||
echo "❌ PostgreSQL is not ready or accessible"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ PostgreSQL is ready!"
|
||||
else
|
||||
# Check if PostgreSQL container is running, start it if not
|
||||
echo "🐋 Checking PostgreSQL container..."
|
||||
if ! docker ps --format '{{.Names}}' | grep -q "^dance-lessons-coach-postgres$"; then
|
||||
echo "🐋 Starting PostgreSQL container..."
|
||||
docker compose up -d postgres
|
||||
|
||||
# Wait for PostgreSQL to be ready
|
||||
echo "⏳ Waiting for PostgreSQL to be ready..."
|
||||
max_attempts=30
|
||||
attempt=0
|
||||
while [ $attempt -lt $max_attempts ]; do
|
||||
if docker exec dance-lessons-coach-postgres pg_isready -U postgres 2>/dev/null; then
|
||||
echo "✅ PostgreSQL is ready!"
|
||||
break
|
||||
fi
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ $attempt -eq $max_attempts ]; then
|
||||
echo "❌ PostgreSQL failed to start"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create BDD test database (separate from development database)
|
||||
echo "📦 Creating BDD test database..."
|
||||
# Drop database if it exists, then create fresh
|
||||
docker exec dance-lessons-coach-postgres psql -U postgres -c "DROP DATABASE IF EXISTS dance_lessons_coach_bdd_test;"
|
||||
if docker exec dance-lessons-coach-postgres createdb -U postgres dance_lessons_coach_bdd_test; then
|
||||
echo "✅ BDD test database created successfully!"
|
||||
else
|
||||
echo "❌ Failed to create BDD test database"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "✅ PostgreSQL container is already running"
|
||||
|
||||
# Check if BDD test database exists, create if not
|
||||
echo "📦 Checking BDD test database..."
|
||||
if docker exec dance-lessons-coach-postgres psql -U postgres -lqt | cut -d \| -f 1 | grep -qw "dance_lessons_coach_bdd_test"; then
|
||||
echo "✅ BDD test database already exists"
|
||||
else
|
||||
echo "📦 Creating BDD test database..."
|
||||
if docker exec dance-lessons-coach-postgres createdb -U postgres dance_lessons_coach_bdd_test; then
|
||||
echo "✅ BDD test database created successfully!"
|
||||
else
|
||||
echo "❌ Failed to create BDD test database"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run the BDD tests
|
||||
test_output=$(go test ./features/... -v 2>&1)
|
||||
test_exit_code=$?
|
||||
|
||||
echo "$test_output"
|
||||
|
||||
# Check for undefined steps
|
||||
if echo "$test_output" | grep -q "undefined"; then
|
||||
echo "❌ FAILED: Found undefined steps"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for pending steps
|
||||
if echo "$test_output" | grep -q "pending"; then
|
||||
echo "❌ FAILED: Found pending steps"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for skipped steps
|
||||
if echo "$test_output" | grep -q "skipped"; then
|
||||
echo "❌ FAILED: Found skipped steps"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if tests passed
|
||||
if [ $test_exit_code -eq 0 ]; then
|
||||
echo "✅ All BDD tests passed successfully!"
|
||||
exit 0
|
||||
else
|
||||
echo "❌ BDD tests failed"
|
||||
echo 'DLC_DATABASE_HOST=localhost DLC_DATABASE_PORT=5432 DLC_DATABASE_USER=postgres DLC_DATABASE_PASSWORD=postgres DLC_DATABASE_NAME=dance_lessons_coach_bdd_test DLC_DATABASE_SSL_MODE=disable go test ./features/... -v'
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user