Skip to content

Add test coverage for masoniteorm make and seed console commands - #155

Merged
tmgbedu merged 7 commits into
mainfrom
task/masoniteorm-commands-coverage-718
Jul 14, 2026
Merged

Add test coverage for masoniteorm make and seed console commands#155
tmgbedu merged 7 commits into
mainfrom
task/masoniteorm-commands-coverage-718

Conversation

@tmgbedu

@tmgbedu tmgbedu commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Adds full test coverage for the masoniteorm make/seed/migrate console commands, rebuilt on current main so it carries the complete test-work history:

The follow-up work (#175/#176/#177) had landed on experiments; it is now consolidated here on top of current main.

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%).

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tmgbedu

tmgbedu commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

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 from ..seeds import Seeder means the mock.patch('...seeds.Seeder', FakeSeeder) correctly intercepts; all seeder-file resolutions and output strings match real logic. Make commands run in isolated temp cwd and assert generated filenames + real file contents. MigrateRefresh asserts rollback + remigrate.

Side effects isolated: No live DB (Seeder mocked), no real file writes (temp cwd + cleanup). git status confirms no leaked artifacts.

Coverage/CI: Commands package 84%; full suite 1618 passed / 7 skipped; total 68.59% ≥ 68%. CI green (Pytest ✅ Ruff ✅ codecov/patch ✅).

MakeModelDocstringCommand exclusion — acceptable: handle() references an undeclared config option + legacy load_config, so it's non-functional (errors on any call). Consistent with the already-skipped ShellCommand.handle. Recommend a separate bug ticket to fix/remove it — out of scope here, not a blocker.

Minor (non-blocking): could add explicit tester.status_code == 0 asserts to harden exit-code checks.

Do NOT merge — approval only.

tmgbedu added 6 commits July 14, 2026 09:46
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().
@tmgbedu
tmgbedu force-pushed the task/masoniteorm-commands-coverage-718 branch from 8471bd9 to f42e957 Compare July 14, 2026 16:48
@tmgbedu
tmgbedu merged commit c051cee into main Jul 14, 2026
6 checks passed
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