#!/bin/bash
# Verify registration bug fix

set -euo pipefail

echo "🔧 Verifying registration bug fix..."

# Navigate to backend
cd /workspace/veza-backend-api

# Run tests
echo "Running unit tests..."
go test ./internal/handlers -v -run TestRegister || {
    echo "❌ Unit tests failed"
    exit 1
}

echo "✅ Unit tests passed"

# Build the application
echo "Building application..."
go build -o bin/veza-api ./main.go || {
    echo "❌ Build failed"
    exit 1
}

echo "✅ Build succeeded"

# Run integration test
cd /workspace/tools/tests
echo "Running integration test..."
bash http/test_registration_bug.sh || {
    echo "❌ Integration test failed"
    exit 1
}

echo "✅ All tests passed! Bug fix verified."