test(orm): real sqlite DB integration tests for seed/migrate commands - #177
Merged
Conversation
…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().
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_db_seed_command.pyandtest_migrate_commands.pyto real sqlite integration tests, per the LaravelMigratorTestphilosophy: boot the real app, run the real command against a real sqlite connection, assert what actually changed in the database.DatabaseSeeder,UserTableSeeder,SampleSeeder,SpecialSeeder) now insert real rows into aseed_userstable via a realSeededUsermodel. Tests assert the resulting rows (SeededUser.all()), not console output or an in-memory call recorder. Dropped therecorder.py/CALLSmechanism as unnecessary now that rows are the source of truth.Schema.has_table/Schema.has_column) and the realmigrationstracking table (MigrationModel.all()) instead of substring-matching command output. Coversdb:migrate,db:migrate:status,db:migrate:rollback,db:migrate:reset,db:migrate:refresh,db:migrate:fresh.SQLitePlatform.compile_column_existsqueriedinformation_schema.columns, which sqlite does not support — this madeSchema.has_column()silently broken/unusable on sqlite. Switched topragma_table_info(). Updated the one existing test that had locked in the broken SQL string.Test plan
grep -rn FakeSeeder .returns nothinguv run pytest tests/masoniteorm/commands/ -v— 37 passed, 1 skippeduv run pytest --ignore=tests/masoniteorm/postgres— 1833 passed, 7 skipped (no regressions)uv run ruff check .anduv run ruff format --check .— clean🤖 Generated with Claude Code