fix/ 修复后端dockerworkflow会跑两次alembic的问题
This commit is contained in:
25
api/tests/test_alembic_revision_ids.py
Normal file
25
api/tests/test_alembic_revision_ids.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
|
||||
REVISION_RE = re.compile(r'^revision: str = "([^"]+)"$', re.MULTILINE)
|
||||
ALEMBIC_VERSION_NUM_MAX_LEN = 32
|
||||
|
||||
|
||||
def test_alembic_revision_ids_fit_default_version_num_column() -> None:
|
||||
versions_dir = Path(__file__).resolve().parent.parent / "alembic" / "versions"
|
||||
too_long: list[tuple[str, int]] = []
|
||||
|
||||
for path in sorted(versions_dir.glob("*.py")):
|
||||
text = path.read_text(encoding="utf-8")
|
||||
match = REVISION_RE.search(text)
|
||||
if match is None:
|
||||
continue
|
||||
revision = match.group(1)
|
||||
if len(revision) > ALEMBIC_VERSION_NUM_MAX_LEN:
|
||||
too_long.append((revision, len(revision)))
|
||||
|
||||
assert not too_long, (
|
||||
"Alembic revision ids exceed the default alembic_version.version_num "
|
||||
f"limit ({ALEMBIC_VERSION_NUM_MAX_LEN}): {too_long}"
|
||||
)
|
||||
Reference in New Issue
Block a user