#!/usr/bin/env bash
set -euo pipefail

# This wrapper intentionally contains no tracing or URL output. The CI service
# uses trust authentication, so the test URL has no password to disclose.
export OSM_LEAD_SOURCE_MIGRATION_ENV=test
export OSM_LEAD_SOURCE_TEST_DATABASE_URL=postgresql+psycopg://test_user@127.0.0.1:5432/osm_lead_source_test

case "${1:-}" in
  migration)
    python -m alembic upgrade head
    python -m alembic downgrade base
    python -m alembic upgrade head
    ;;
  integration)
    python -m pytest tests/integration/sidecar
    ;;
  full)
    python -m pytest
    ;;
  *)
    echo "usage: scripts/ci-test-db.sh {migration|integration|full}" >&2
    exit 2
    ;;
esac
