Files
xiaoxia-saas/tests/unit/test_alembic_preflight.py
T
Xiaoxia AI 747a1c0ad3
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 10s
Deploy / Deploy Staging (push) Successful in 2m0s
Deploy / Deploy Production (push) Has been skipped
chore(release): add alembic preflight check
2026-06-21 13:01:49 +08:00

46 lines
1.2 KiB
Python

from scripts.alembic_preflight import AlembicPreflightResult
def test_alembic_preflight_action_for_current_version():
result = AlembicPreflightResult(
has_alembic_version=True,
business_table_count=12,
current_revision="002",
head_revision="002",
)
assert result.action == "upgrade_head_noop_or_verify"
def test_alembic_preflight_action_for_old_version():
result = AlembicPreflightResult(
has_alembic_version=True,
business_table_count=12,
current_revision="001",
head_revision="002",
)
assert result.action == "upgrade_head"
def test_alembic_preflight_action_for_existing_tables_without_version():
result = AlembicPreflightResult(
has_alembic_version=False,
business_table_count=12,
current_revision=None,
head_revision="002",
)
assert result.action == "stamp_head_then_upgrade_head"
def test_alembic_preflight_action_for_empty_database():
result = AlembicPreflightResult(
has_alembic_version=False,
business_table_count=0,
current_revision=None,
head_revision="002",
)
assert result.action == "upgrade_head_empty_database"