test(proxy): cover the dry run CLI and PrismaManager wrapper without a database

This commit is contained in:
devin-ai-integration[bot] 2026-10-29 01:19:57 +00:00
parent 53d8f0d72e
commit 883cbf259d
2 changed files with 33 additions and 0 deletions

View file

@ -586,3 +586,19 @@ async def test_a_query_issued_while_the_last_one_finishes_keeps_the_engine_drain
await second
await asyncio.wait_for(drained, timeout=1)
assert engine.queries_finished == 2
def test_migration_dry_run_summary_without_migrations_has_nothing_to_dry_run(unset_database_url):
"""`prisma db push` applies no migration files, so the dry run reports that instead of connecting."""
from litellm.proxy.db.prisma_client import PrismaManager
assert PrismaManager.migration_dry_run_summary(use_migrate=False) == (
True,
"The schema is pushed rather than migrated, there is nothing to dry-run.",
)
def test_migration_dry_run_summary_needs_database_url(unset_database_url):
from litellm.proxy.db.prisma_client import PrismaManager
assert PrismaManager.migration_dry_run_summary(use_migrate=True) == (False, "DATABASE_URL is not set.")

View file

@ -4073,3 +4073,20 @@ def test_granian_flag_notices_are_json_records_in_json_mode(
"LiteLLM: --ciphers is not applied when using --run_granian.",
]
assert {record["level"] for record in records} == {"INFO"}
def test_migration_data_check_exits_zero_when_there_is_nothing_to_dry_run(monkeypatch, capfd):
monkeypatch.setenv("DATABASE_URL", "postgresql://user:pass@db.example/litellm")
assert ProxyInitializationHelpers.run_migration_data_check(use_migrate=False) == 0
out, err = capfd.readouterr()
assert out == "LiteLLM Proxy: The schema is pushed rather than migrated, there is nothing to dry-run.\n"
assert err == ""
def test_migration_data_check_requires_database_url(monkeypatch):
monkeypatch.delenv("DATABASE_URL", raising=False)
with pytest.raises(click.UsageError, match="requires DATABASE_URL"):
ProxyInitializationHelpers.run_migration_data_check(use_migrate=True)