Skip to content

test(orm): real sqlite DB integration tests for seed/migrate commands - #177

Merged
tmgbedu merged 1 commit into
experimentsfrom
task/fakeseeder-realdb-1004
Jul 14, 2026
Merged

test(orm): real sqlite DB integration tests for seed/migrate commands#177
tmgbedu merged 1 commit into
experimentsfrom
task/fakeseeder-realdb-1004

Conversation

@tmgbedu

@tmgbedu tmgbedu commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Rewrites test_db_seed_command.py and test_migrate_commands.py to real sqlite integration tests, per the Laravel MigratorTest philosophy: boot the real app, run the real command against a real sqlite connection, assert what actually changed in the database.
  • Seed tests: fixture seeder classes (DatabaseSeeder, UserTableSeeder, SampleSeeder, SpecialSeeder) now insert real rows into a seed_users table via a real SeededUser model. Tests assert the resulting rows (SeededUser.all()), not console output or an in-memory call recorder. Dropped the recorder.py/CALLS mechanism as unnecessary now that rows are the source of truth.
  • Migrate tests: assert real schema state (Schema.has_table / Schema.has_column) and the real migrations tracking table (MigrationModel.all()) instead of substring-matching command output. Covers db:migrate, db:migrate:status, db:migrate:rollback, db:migrate:reset, db:migrate:refresh, db:migrate:fresh.
  • One minimal, secondary output assertion is kept per file for the user-facing message contract only — behavior is proven by DB state, not text.
  • Framework fix found along the way: SQLitePlatform.compile_column_exists queried information_schema.columns, which sqlite does not support — this made Schema.has_column() silently broken/unusable on sqlite. Switched to pragma_table_info(). Updated the one existing test that had locked in the broken SQL string.
  • No mocks/fakes of the Seeder, Migrator, or command classes anywhere in either file.

Test plan

  • grep -rn FakeSeeder . returns nothing
  • uv run pytest tests/masoniteorm/commands/ -v — 37 passed, 1 skipped
  • uv run pytest --ignore=tests/masoniteorm/postgres — 1833 passed, 7 skipped (no regressions)
  • uv run ruff check . and uv run ruff format --check . — clean

🤖 Generated with Claude Code

…ration style

Replace mock/output-based assertions with real database state checks,
mirroring Laravel's MigratorTest philosophy: boot the real app, run the
real command against a real sqlite connection, and assert what actually
changed in the database rather than what was printed or called.

Seed-command tests: fixture seeder classes now insert real rows into a
'seed_users' table via a real Model; tests assert the resulting rows
instead of console output or an in-memory call recorder.

Migrate-command tests: assert real schema state (has_table/has_column)
and the real migrations tracking table instead of substring-matching
command output.

Fixes a latent bug found along the way: SQLitePlatform.compile_column_exists
queried information_schema.columns, which sqlite does not support, making
Schema.has_column() unusable on sqlite. Switched to pragma_table_info().
@tmgbedu
tmgbedu merged commit da3eed4 into experiments Jul 14, 2026
5 checks passed
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant