Add test coverage for masoniteorm make and seed console commands#155
Add test coverage for masoniteorm make and seed console commands#155tmgbedu wants to merge 1 commit into
Conversation
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.
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. |
Summary
Adds unit tests for the previously untested Cleo database commands under
fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/, addressing the low Codecov coverage on that package (task #718).Coverage for the
masoniteorm/commandspackage rises to ~84% (from the make/seed commands being near 0%).What's covered
test_make_commands.py—db:make:migration,db:make:model,seed(make seeder),observer--create,--table,--directory,--pep,--model), the generated file contents, and the "already exists" guard paths.test_db_seed_command.py—db:seed--classvariants (plain name,TableSeedersuffix, dotted path), plus--connection/--directoryforwarding.Seederthat records constructor args and awaited methods, mocking DB side effects.test_migrate_commands.py— adds adb:migrate:refreshtest asserting the reset + re-migrate path.Testing
uv run pytest tests/masoniteorm/commands/ --cov=src/fastapi_startkit/masoniteorm/commands→ 32 passed, 1 skippeduv run pytest --ignore=tests/masoniteorm/postgres→ 1618 passed, 7 skippedNotes
MakeModelDocstringCommandis left uncovered: itshandle()relies on the legacyload_config()/ a non-existentconfigoption and is non-functional in the current framework (same situation as the already-skippedShellCommand.handle()test).