test: add mock tests for 8 executor handler files#253
Conversation
Add 49 tests across 8 new test files covering executor handlers that previously had zero test coverage: - cmd_folders: 9 tests (DropFolder + MoveFolder paths) - cmd_move: 6 tests (page moves, cross-module refs, error paths) - cmd_rename: 11 tests (entity/module/microflow/page/enum/assoc/const/nanoflow) - cmd_alter_page: 9 tests (set property, snippets, widgets, variables, layout) - cmd_features: 7 tests (ForVersion, AddedSince, connected, invalid version) - cmd_styling: 5 tests (not-connected guards for all 3 styling commands) - cmd_lint: 1 test (not-connected guard) - cmd_import: 1 test (not-connected guard) Styling, lint, and import have partial coverage (not-connected + error paths only) because their happy paths depend on filesystem or external DB connections that cannot be mocked through the current Backend interface.
AI Code ReviewWhat Looks Good
RecommendationApprove - This PR successfully addresses a critical testing gap by adding meaningful unit tests for executor handlers using the established mock backend infrastructure. The tests are well-written, honestly scoped to what can be mocked, and follow existing project patterns. The limitations for certain handlers are appropriately documented and understood. No changes are needed. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
Adds mock-backed unit tests to improve coverage for executor handlers that previously had none/limited coverage, leveraging the existing MockBackend + newMockCtx test infrastructure.
Changes:
- Introduces 8 new
*_mock_test.gofiles coveringcmd_folders,cmd_move,cmd_rename,cmd_alter_page,cmd_features,cmd_styling,cmd_lint, andcmd_import. - Exercises key branches: not-connected guards, happy paths (where feasible), not-found/unsupported cases, and representative backend error propagation.
- Documents known gaps where current
Backendmocking can’t reasonably cover filesystem/BSON/SQL-dependent paths.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| mdl/executor/cmd_styling_mock_test.go | Adds guard-rail tests for styling handlers (not connected / missing project path). |
| mdl/executor/cmd_rename_mock_test.go | Adds broad rename coverage across entity/module/document types, including dry-run and backend error cases. |
| mdl/executor/cmd_move_mock_test.go | Adds move coverage for pages (folder moves, cross-module reference updates, not-found/unsupported, backend error). |
| mdl/executor/cmd_lint_mock_test.go | Adds lint tests for not-connected and the ShowRules branch output. |
| mdl/executor/cmd_import_mock_test.go | Adds minimal import coverage for the not-connected guard. |
| mdl/executor/cmd_folders_mock_test.go | Adds coverage for drop/move folder flows including nested paths and backend errors. |
| mdl/executor/cmd_features_mock_test.go | Adds coverage for show-features behavior across connected/disconnected and version parsing paths. |
| mdl/executor/cmd_alter_page_mock_test.go | Adds alter-page/snippet coverage for several mutator operations plus open/save error propagation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code ReviewOverviewAdds 49 unit tests across 8 new Code Quality & StyleStrengths:
Minor issues:
CorrectnessNo behavioral issues found. The mock wiring is correct — backends are set up with exactly the methods the handler will call, nothing more.
Coverage Limitations (documented, appropriate)The PR honestly documents what can't be reached with the current mock infrastructure ( One undocumented gap: Suggestions
Verdict: Approve with minor suggestions. Solid safety-net addition — consistent patterns, honest documentation of limitations, and correct mock wiring throughout. |
Why
The mxcli project is preparing to extract the
mdl/runtime into a reusable library. Before any refactoring can safely begin, comprehensive test coverage is needed to catch behavioral regressions from renaming, splitting files, extracting interfaces, and moving packages. Phase 1 (PRs #222–#239) established the architectural foundation; Phase 2 builds the test safety net.This PR targets 8 executor handler files that had zero test coverage — any refactoring of these handlers would have no regression protection without these tests.
Part of the stacked PR series: #253 (C1) → #254 (C2) → #255 (D1).
Summary
*_mock_test.gofiles covering executor handlers that previously had zero test coveragecmd_folders,cmd_move,cmd_rename,cmd_alter_page,cmd_features,cmd_styling,cmd_lint,cmd_importmock_test_helpers_test.go)Coverage breakdown
cmd_renamecmd_alter_pagecmd_folderscmd_featurescmd_movecmd_stylingcmd_lintcmd_importNotes
cmd_styling,cmd_lint, andcmd_importhave documented limitations — their happy paths depend on filesystem I/O, BSON parsing, or SQL connections that cannot be mocked through the currentBackendinterface