test(postgres): allow Testcontainers to override the migration sqlalchemy.url
alembic/env.py previously always overwrote sqlalchemy.url from Settings().postgres.dsn, which made it impossible for a test fixture to point Alembic at a Testcontainers-managed database. Now env.py only sets it when unset, and a new integration suite runs `alembic upgrade head` against a real Postgres container per ADR-0016 (no create_all()).
This commit is contained in:
23
tests/integration/postgres/test_migrations.py
Normal file
23
tests/integration/postgres/test_migrations.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import pytest
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.ext.asyncio import AsyncEngine
|
||||
|
||||
pytestmark = [pytest.mark.integration, pytest.mark.postgres, pytest.mark.asyncio]
|
||||
|
||||
EXPECTED_TABLES = {
|
||||
"tenants",
|
||||
"api_keys",
|
||||
"source_files",
|
||||
"ingestion_jobs",
|
||||
"ingestion_job_events",
|
||||
"alembic_version",
|
||||
}
|
||||
|
||||
|
||||
async def test_migrations_create_schema_from_empty_database(postgres_engine: AsyncEngine) -> None:
|
||||
async with postgres_engine.connect() as connection:
|
||||
table_names = await connection.run_sync(
|
||||
lambda sync_conn: inspect(sync_conn).get_table_names()
|
||||
)
|
||||
|
||||
assert EXPECTED_TABLES.issubset(set(table_names))
|
||||
Reference in New Issue
Block a user