test: expand mock tests for 28 executor handler files#254
test: expand mock tests for 28 executor handler files#254ako merged 6 commits intomendixlabs:mainfrom
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.
…ions, constants, microflows
…avascript_actions
…ctions, jsonstructures, mappings, mermaid, navigation
AI Code ReviewWhat Looks Good
RecommendationApprove - This PR provides valuable test coverage expansion that improves code robustness while following project testing conventions. No issues found with overlap, syntax design, full-stack consistency (not applicable as no new MDL features), security, scope, or code quality. The tests appropriately extend existing patterns without duplication. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
This PR expands mock-based test coverage across many executor handler areas, exercising previously untested branches (not-found, module filtering, backend error propagation, JSON output, and a few edge cases). It builds on the existing mock backend + newMockCtx helper infrastructure to cover more handler behavior without requiring filesystem/DB/BSON-heavy setups.
Changes:
- Added/expanded mock tests across a broad set of
cmd_*_mock_test.gofiles to cover not-found paths, module filtering, and backend error propagation. - Added JSON-format assertions (
assertValidJSON) for additional list handlers. - Added targeted edge-case tests (e.g., nil-name validation, unsupported type errors, “already exists” guards).
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mdl/executor/cmd_write_handlers_mock_test.go | Adds mock tests for additional write-handler branches (already-exists + not-found paths). |
| mdl/executor/cmd_workflows_mock_test.go | Adds not-found + filter-by-module tests for workflow handlers. |
| mdl/executor/cmd_styling_mock_test.go | Introduces coverage for “not connected” and missing-project-path guards in styling commands. |
| mdl/executor/cmd_settings_mock_test.go | Adds not-connected/backend-error/JSON coverage for settings listing/describe. |
| mdl/executor/cmd_security_mock_test.go | Adds module filtering + not-found/edge-case coverage for security-related describe/list helpers. |
| mdl/executor/cmd_rest_clients_mock_test.go | Adds not-found + filter-by-module tests for REST client handlers. |
| mdl/executor/cmd_rename_mock_test.go | Adds comprehensive mock coverage for rename command across types and failure modes. |
| mdl/executor/cmd_published_rest_mock_test.go | Adds not-found + filter-by-module tests for published REST handlers. |
| mdl/executor/cmd_pages_mock_test.go | Adds filter-by-module tests for snippets/layouts and not-found tests for describe paths. |
| mdl/executor/cmd_odata_mock_test.go | Adds not-found + module-filtering coverage for OData client/service handlers. |
| mdl/executor/cmd_navigation_mock_test.go | Adds not-found and “all profiles” describe coverage for navigation. |
| mdl/executor/cmd_move_mock_test.go | Adds mock coverage for move command (not connected, not found, cross-module refs, backend error). |
| mdl/executor/cmd_modules_mock_test.go | Adds backend error + JSON output coverage for module listing. |
| mdl/executor/cmd_misc_mock_test.go | Adds not-connected and “no schema hash” coverage for version output + help smoke test. |
| mdl/executor/cmd_microflows_mock_test.go | Adds notes pointing to existing cross-cutting backend-error/JSON tests. |
| mdl/executor/cmd_mermaid_mock_test.go | Adds microflow + error-path coverage for mermaid output generation. |
| mdl/executor/cmd_lint_mock_test.go | Adds tests for not-connected and ShowRules branch. |
| mdl/executor/cmd_jsonstructures_mock_test.go | Adds module filtering + describe + not-found coverage for JSON structures. |
| mdl/executor/cmd_javascript_actions_mock_test.go | Adds not-found + module filtering coverage for JavaScript actions. |
| mdl/executor/cmd_javaactions_mock_test.go | Adds backend error + not-found + module filtering + JSON coverage for Java actions. |
| mdl/executor/cmd_import_mock_test.go | Adds not-connected coverage for import command (documents mock limitations). |
| mdl/executor/cmd_import_mappings_mock_test.go | Adds module filtering + describe + not-found coverage for import mappings. |
| mdl/executor/cmd_imagecollections_mock_test.go | Adds module filtering + not-found coverage for image collections. |
| mdl/executor/cmd_fragments_mock_test.go | Adds describe + not-found coverage for fragment handling. |
| mdl/executor/cmd_folders_mock_test.go | Adds mock coverage for folder drop/move command branches and error paths. |
| mdl/executor/cmd_features_mock_test.go | Adds coverage for version-based feature listing and validation error cases. |
| mdl/executor/cmd_export_mappings_mock_test.go | Adds module filtering + describe + not-found coverage for export mappings. |
| mdl/executor/cmd_enumerations_mock_test.go | Adds notes pointing to existing cross-cutting backend-error/JSON tests. |
| mdl/executor/cmd_entities_mock_test.go | Adds backend error + JSON output coverage for entity listing. |
| mdl/executor/cmd_dbconnection_mock_test.go | Adds module filtering + not-found coverage for database connections. |
| mdl/executor/cmd_datatransformer_mock_test.go | Adds module filtering + not-found coverage for data transformers. |
| mdl/executor/cmd_constants_mock_test.go | Adds notes pointing to existing cross-cutting backend-error/JSON tests. |
| mdl/executor/cmd_businessevents_mock_test.go | Adds not-found + module filtering coverage for business event services. |
| mdl/executor/cmd_associations_mock_test.go | Adds backend error + JSON output coverage for association listing. |
| mdl/executor/cmd_alter_page_mock_test.go | Adds mock coverage for alter page/snippet behavior and error paths via page mutator. |
| mdl/executor/cmd_agenteditor_mock_test.go | Expands agent editor mock tests with not-found/drop-not-found and module filtering cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
53fd846 to
dccb33d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code ReviewOverviewThis is C2 in the stacked series (#253 → #254 → #255), adding ~95 tests across 28 executor handler files. The coverage is systematic and well-organized: not-found paths, filter-by-module, backend error propagation, JSON output, and edge cases. The test structure is consistent throughout and the inline documentation comments (explaining WHY certain paths are left uncovered, with "tracked separately" notes) are a good pattern. Blocking issue
The test calls func execHelp(ctx *ExecContext, s *ast.HelpStmt) error {This was changed during the PR #172 rebase (syntax feature registry). The fix is either: // Option A — test the no-topic path
assertNoError(t, execHelp(ctx, &ast.HelpStmt{}))or extract a zero-arg wrapper if the REPL really does call Non-blocking issues
Strengths
SummaryOne hard compile error ( |
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. PR #253 (C1) added initial mock tests for 8 handler files that had zero coverage. This PR completes the executor handler coverage by expanding the remaining 28 handler files that had only minimal tests (typically just a happy-path case).Without these tests, error paths, filter logic, and edge cases in these handlers would go unvalidated during refactoring — exactly the kind of subtle breakage that is hardest to catch.
Part of the stacked PR series: #253 (C1) → #254 (C2) → #255 (D1).
Summary
*_mock_test.gofiles that previously had minimal testsBatch breakdown
What's covered
assertValidJSONfor list handlersNotes
cmd_notconnected_mock_test.go,cmd_error_mock_test.go,cmd_json_mock_test.go) already cover not-connected, backend errors, and JSON for many handlers — new tests avoid duplication