test: cover database migration helpers#4875
Conversation
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
saim256
left a comment
There was a problem hiding this comment.
Reviewed current head 54140ef. The new migration-runner tests are scoped to the added test file, import the hyphenated tool module without changing production code, cover UP/DOWN parsing, missing DOWN blocks, migration discovery ordering/name filtering, checksum presence, and SQL-block execution across empty statements. The tests also preserve the existing backup verification coverage requested in the PR body.\n\nValidation run locally on Windows:\n- python -m pytest tests\test_db_migrate.py tests\test_verify_backup.py -q -> 6 passed\n- python -m py_compile tests\test_db_migrate.py tools\db-migrate\migrate.py tests\test_verify_backup.py -> passed\n- git diff --check origin/main...pr-4875 -> passed\n- python tools\bcos_spdx_check.py --base-ref origin/main -> OK
508704820
left a comment
There was a problem hiding this comment.
Code Review: Cover Database Migration Helpers
Summary
Adds 97-line test file for db-migrate tool. Tests migration file parsing (UP/DOWN blocks), migration ordering, and SQL execution.
What Works Well
- importlib.util: Loads migrate module directly
- UP/DOWN block parsing: Tests the core migration format
- 97 lines: Good coverage of migration helper logic
- tmp_path: Clean test isolation
Verdict: Approve
Good test coverage for database migration tooling.
loganoe
left a comment
There was a problem hiding this comment.
Reviewed the db-migrate test coverage. The tests exercise migration parsing, discovery ordering/name normalization, and SQL block execution without changing production migration code. I could not run pytest directly in this checkout because tests/conftest.py imports Flask and this environment lacks Flask, but I manually loaded tests/test_db_migrate.py and executed all four test functions successfully: manual db-migrate tests passed.
Draft PR for review.
Related bounty: Scottcjn/rustchain-bounties#1589
Summary
tools/db-migrate/migrate.py.Verification
/tmp/rustchain-bounty-venv/bin/python -m pytest tests/test_db_migrate.py -q/tmp/rustchain-bounty-venv/bin/python -m pytest tests/test_db_migrate.py tests/test_verify_backup.py -q