Add test coverage for masoniteorm make and seed console commands - #155
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Code Review Verdict: APPROVE ✅ (posted as comment — GH blocks self-approval)Test-only PR (279 additions, 0 deletions). Verified against real command implementations. Correctness: Tests assert real behavior. DBSeedCommand's call-time Side effects isolated: No live DB (Seeder mocked), no real file writes (temp cwd + cleanup). Coverage/CI: Commands package 84%; full suite 1618 passed / 7 skipped; total 68.59% ≥ 68%. CI green (Pytest ✅ Ruff ✅ codecov/patch ✅). MakeModelDocstringCommand exclusion — acceptable: Minor (non-blocking): could add explicit Do NOT merge — approval only. |
Cover the previously untested Cleo commands in masoniteorm/commands: db:make:migration, db:make:model, seed (make seeder), observer, db:seed and db:migrate:refresh. Generator commands are exercised in an isolated temp working directory and assert on the emitted files and CLI output. db:seed is tested with a fake Seeder that records constructor args and awaited methods, mocking database side effects while verifying argument/option parsing and the handle path.
Consolidate test_db_seed_command.py and test_seed_commands.py into a
single TestDBSeedCommand(unittest.TestCase). setUp now builds a real
Application via fixtures.app.create_app(); option/argument-resolution
tests keep driving the command directly through CommandTester (needed
for the mocked-Seeder assertions and for the exception paths, since the
console app swallows command exceptions), while the fixture-backed
end-to-end tests now run through self.app.run("db:seed", ...).
Replace the hand-rolled FakeSeeder class in test_db_seed_command.py with mock.patch(..., autospec=True) against the real Seeder, asserting constructor args and awaited calls directly. Same cleanup already applied on the PR #155 branch (commit 8471bd9) but missed on the experiments seeds->seeders refactor (PR #175).
…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().
8471bd9 to
f42e957
Compare
Adds full test coverage for the masoniteorm make/seed/migrate console commands, rebuilt on current
mainso it carries the complete test-work history:databases/seedersrenameThe follow-up work (#175/#176/#177) had landed on
experiments; it is now consolidated here on top of currentmain.Testing:
uv run pytest tests/masoniteorm/commands/ -v→ 37 passed, 1 skipped. Full suite (excluding live-Postgres tests, which require a running DB) → 1833 passed, 7 skipped, coverage 79.87% (threshold 68%).