Skip to content

test: cover database migration helpers#4875

Draft
Vinayak1337 wants to merge 1 commit into
Scottcjn:mainfrom
Vinayak1337:bounty/rustchain-db-migrate-tests-1589
Draft

test: cover database migration helpers#4875
Vinayak1337 wants to merge 1 commit into
Scottcjn:mainfrom
Vinayak1337:bounty/rustchain-db-migrate-tests-1589

Conversation

@Vinayak1337
Copy link
Copy Markdown

Draft PR for review.

Related bounty: Scottcjn/rustchain-bounties#1589

Summary

  • Adds pytest coverage for the database migration runner helpers in tools/db-migrate/migrate.py.
  • Covers UP/DOWN parsing, missing DOWN blocks, migration discovery sorting/invalid-file skipping, and SQL block execution with empty statements.

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

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) tests Test suite changes labels May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Your PR has a BCOS-L1 or BCOS-L2 label
  • New code files include an SPDX license header
  • You've tested your changes against the live node

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!

@github-actions github-actions Bot added the size/M PR: 51-200 lines label May 12, 2026
Copy link
Copy Markdown

@saim256 saim256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

@508704820 508704820 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. importlib.util: Loads migrate module directly
  2. UP/DOWN block parsing: Tests the core migration format
  3. 97 lines: Good coverage of migration helper logic
  4. tmp_path: Clean test isolation

Verdict: Approve

Good test coverage for database migration tooling.

Copy link
Copy Markdown

@loganoe loganoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants