test(catalog): add unit tests for builder pure helper functions#256
test(catalog): add unit tests for builder pure helper functions#256ako merged 2 commits intomendixlabs:mainfrom
Conversation
AI Code ReviewWhat Looks Good
RecommendationThe PR is ready to be approved. It adds valuable test coverage for existing helper functions without introducing any new MDL syntax or features, making it a safe and necessary improvement for code maintainability. The tests are thorough, well-written, and directly support the project's refactoring preparations. No changes are requested. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
27cb9aa to
f5c241a
Compare
AI Code ReviewWhat Looks Good
Recommendation
Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
Adds substantial unit-test coverage for previously lightly/untested helper logic and command paths to support upcoming mdl/ runtime refactoring into a reusable library.
Changes:
- Add new unit tests for multiple
mdl/linter/ruleshelper functions and rule metadata/nil-reader guards. - Expand
mdl/executormock tests with additional not-connected, not-found, filter-by-module, JSON, and backend-error scenarios across many commands. - Add new unit tests for several
mdl/catalogbuilder “pure helper” functions (microflows, pages, permissions, workflows, navigation, modules).
Reviewed changes
Copilot reviewed 54 out of 54 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mdl/linter/rules/validation_feedback_test.go | Unit tests for empty-template detection and microflow object walking for MPR004. |
| mdl/linter/rules/security_test.go | Tests for SEC001 plus nil-reader guard + metadata tests for SEC002/SEC003. |
| mdl/linter/rules/page_navigation_security_test.go | Tests for menu-page collection/module parsing + nil-reader guard for MPR007. |
| mdl/linter/rules/naming_test.go | Unit tests for naming helpers/patterns and MPR001 metadata. |
| mdl/linter/rules/mpr008_overlapping_activities_test.go | Nil-reader guard/metadata + constant checks for MPR008. |
| mdl/linter/rules/helpers_test.go | Shared test helpers (synthetic microflow + in-memory SQLite setup). |
| mdl/linter/rules/empty_test.go | In-memory DB tests for MPR002 empty-microflow rule + metadata. |
| mdl/linter/rules/empty_container_test.go | Unit tests for empty container detection + MPR006 metadata. |
| mdl/linter/rules/domain_size_test.go | In-memory DB tests for MPR003 domain-model size rule + metadata. |
| mdl/linter/rules/conv_split_caption_test.go | Unit tests for CONV012 exclusive-split caption walker + metadata. |
| mdl/linter/rules/conv_loop_commit_test.go | Unit tests for CONV011 loop commit walker + nil-reader guard/metadata. |
| mdl/linter/rules/conv_error_handling_test.go | Unit tests for CONV013/CONV014 walker functions + metadata. |
| mdl/executor/cmd_write_handlers_mock_test.go | Adds mock coverage for already-exists and multiple not-found drop paths. |
| mdl/executor/cmd_workflows_mock_test.go | Adds not-found + filter-by-module coverage for workflows. |
| mdl/executor/cmd_styling_mock_test.go | New mock tests for styling commands’ not-connected / missing-path guards. |
| mdl/executor/cmd_settings_mock_test.go | Adds not-connected/backend-error/JSON tests for settings listing. |
| mdl/executor/cmd_security_mock_test.go | Adds filter-by-module + various not-found/unsupported/invalid-input tests for security commands. |
| mdl/executor/cmd_rest_clients_mock_test.go | Adds not-found + filter-by-module coverage for REST clients. |
| mdl/executor/cmd_rename_mock_test.go | New comprehensive mock tests for rename (connected guards, happy paths, errors, dry-run). |
| mdl/executor/cmd_published_rest_mock_test.go | Adds not-found + filter-by-module coverage for published REST services. |
| mdl/executor/cmd_pages_mock_test.go | Adds filter-by-module tests for snippets/layouts and not-found describe tests. |
| mdl/executor/cmd_odata_mock_test.go | Adds not-found + filter-by-module coverage for consumed/published OData. |
| mdl/executor/cmd_navigation_mock_test.go | Adds not-found + “all profiles” describe coverage for navigation. |
| mdl/executor/cmd_move_mock_test.go | New mock tests for move (guards, happy path, cross-module ref updates, errors). |
| mdl/executor/cmd_modules_mock_test.go | Adds backend-error + JSON coverage for module listing. |
| mdl/executor/cmd_misc_mock_test.go | Adds not-connected + no-schema-hash coverage for version output; adds help test. |
| mdl/executor/cmd_microflows_mock_test.go | Adds notes referencing existing error/JSON coverage (comment-only change). |
| mdl/executor/cmd_mermaid_mock_test.go | Adds microflow happy/not-found + page not-found + unsupported-type coverage. |
| mdl/executor/cmd_lint_mock_test.go | New tests for execLint not-connected + ShowRules path. |
| mdl/executor/cmd_jsonstructures_mock_test.go | Adds filter-by-module + describe/not-found coverage for JSON structures. |
| mdl/executor/cmd_javascript_actions_mock_test.go | Adds not-found + filter-by-module tests for JS actions. |
| mdl/executor/cmd_javaactions_mock_test.go | Adds backend-error/not-found/filter-by-module/JSON tests for Java actions. |
| mdl/executor/cmd_import_mock_test.go | New test for execImport not-connected guard (documents limitations). |
| mdl/executor/cmd_import_mappings_mock_test.go | Adds filter-by-module + describe/not-found coverage for import mappings. |
| mdl/executor/cmd_imagecollections_mock_test.go | Adds filter-by-module + not-found coverage for image collections. |
| mdl/executor/cmd_fragments_mock_test.go | Adds describe/not-found/nil-fragments coverage for fragments. |
| mdl/executor/cmd_folders_mock_test.go | New mock tests for drop/move folder scenarios (guards, success, errors, nested path). |
| mdl/executor/cmd_features_mock_test.go | New mock tests for features command across connected/disconnected + version parsing cases. |
| mdl/executor/cmd_export_mappings_mock_test.go | Adds filter-by-module + describe/not-found coverage for export mappings. |
| mdl/executor/cmd_enumerations_mock_test.go | Adds notes referencing existing error/JSON coverage (comment-only change). |
| mdl/executor/cmd_entities_mock_test.go | Adds backend-error + JSON coverage for entity listing. |
| mdl/executor/cmd_dbconnection_mock_test.go | Adds filter-by-module + not-found coverage for DB connections. |
| mdl/executor/cmd_datatransformer_mock_test.go | Adds filter-by-module + not-found coverage for data transformers. |
| mdl/executor/cmd_constants_mock_test.go | Adds notes referencing existing error/JSON coverage (comment-only change). |
| mdl/executor/cmd_businessevents_mock_test.go | Adds not-found + filter-by-module coverage for business event services. |
| mdl/executor/cmd_associations_mock_test.go | Adds backend-error + JSON coverage for association listing. |
| mdl/executor/cmd_alter_page_mock_test.go | New mock tests for alter page/snippet operations and error cases. |
| mdl/executor/cmd_agenteditor_mock_test.go | Adds not-found/drop-not-found + filter-by-module coverage for agent editor types. |
| mdl/catalog/builder_workflows_test.go | Unit tests for workflow activity counters and recursion. |
| mdl/catalog/builder_permissions_test.go | Unit tests for permission derivation from member access rights. |
| mdl/catalog/builder_pages_test.go | Unit tests for page/snippet widget extraction + BSON/GUID utilities. |
| mdl/catalog/builder_navigation_test.go | Unit tests for navigation menu item counting. |
| mdl/catalog/builder_modules_test.go | Unit tests for qualified attribute-name extraction. |
| mdl/catalog/builder_microflows_test.go | Unit tests for microflow/nanoflow type switches, activity counting, and complexity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 54 out of 54 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code ReviewOverviewE1 in the stacked series (#253 → #254 → #255 → #256). Six new test files covering pure helper functions in Blocking issue (inherited from #254)
Non-blocking issues
{
name: "short data — returns as string",
data: []byte{0x01, 0x02},
want: "\x01\x02",
},
The implementation skips both Strengths
SummaryOne blocking compile error (inherited from #254). Three minor coverage gaps worth addressing. The core value of this PR — testing GUID byte-swap logic, complexity counting, and BSON extraction helpers — is well-executed and exactly what's needed before extracting the |
f5c241a to
f84885a
Compare
AI Code ReviewWhat Looks Good
RecommendationApprove - The PR adds valuable test coverage for pure helper functions in preparation for refactoring, following the project's testing practices and checklist requirements. The tests are well-written, comprehensive, and appropriately scoped. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
Cover getMicroflowObjectType, getMicroflowActionType, getDataTypeName, countMicroflowActivities, calculateMcCabeComplexity, countNanoflowActivities, calculateNanoflowComplexity, extractLayoutRef, extractPageWidgets, extractWidgetsRecursive, extractSnippetWidgets, getBsonArrayElements, toBsonArray, extractString, extractBsonID, decodeBase64GUID, extractBinaryID, formatGUID, bytesToHex, entityAccessFromMemberRights, countWorkflowActivityTypes, countMenuItems, extractAttrName.
- Add default/unknown test case for getMicroflowObjectType - Replace non-printable bytes in formatGUID short-data test with legible ASCII - Add Pages$DivContainer test case to TestExtractWidgetsRecursive
f84885a to
5bd8d68
Compare
|
Thanks for the review! Pushed fixes in a separate commit (5bd8d68), rebased on main after D1 merge: Blocking issue (TestHelp_Mock): Same as D1 — Non-blocking fixes applied:
|
Summary
Why
Preparing to extract the
mdl/runtime into a reusable library — comprehensive test coverage is needed before refactoring.Test files
builder_microflows_test.gogetMicroflowObjectType,getMicroflowActionType,getDataTypeName,countMicroflowActivities,calculateMcCabeComplexity,countNanoflowActivities,calculateNanoflowComplexitybuilder_pages_test.goextractLayoutRef,extractPageWidgets,extractWidgetsRecursive,extractSnippetWidgets,getBsonArrayElements,toBsonArray,extractString,extractBsonID,decodeBase64GUID,extractBinaryID,formatGUID,bytesToHexbuilder_permissions_test.goentityAccessFromMemberRightsbuilder_workflows_test.gocountWorkflowActivityTypesbuilder_navigation_test.gocountMenuItemsbuilder_modules_test.goextractAttrNameStacked on
test/linter-rule-coverage) — D1test/handler-mock-expand) — C2test/executor-mock-tests) — C1