test: add visitor tests for 20 untested source files#245
test: add visitor tests for 20 untested source files#245retran wants to merge 11 commits intomendixlabs:mainfrom
Conversation
When setting PAGE on a workflow activity where the TaskPage BSON key is absent (not just nil), dSet silently failed because it only updates existing keys. Added replaceActivity helper that appends the key to the activity document and replaces it in the BSON tree by match. Three cases now handled correctly: - TaskPage exists with value: update Page field in place - TaskPage exists with nil value: replace via dSet - TaskPage absent: append key, replace activity in tree
…ss test Add mock implementations of PageMutator (16 methods) and WorkflowMutator (15 methods) using the same Func-field delegation pattern as MockBackend. Both include compile-time interface checks. Fix allKnownStatements() to include 8 missing agent editor statement types (CreateAgent, DropAgent, CreateModel, DropModel, CreateConsumedMCPService, DropConsumedMCPService, CreateKnowledgeBase, DropKnowledgeBase). Add handler count snapshot test.
Cover security (24 tests), odata (4), agent editor (4), REST (2), settings (4), module (1), association (3), connection (2), business events (1), enumeration (5), JSON structure (1), data transformer (1), widgets (2), image collection (1), navigation (1), lint (4), import/export mapping (2), move (2), misc queries (4), and database connection (1). Visitor test function count: 128 -> 197 (+69).
There was a problem hiding this comment.
Pull request overview
Adds broad test coverage for previously untested MDL visitor statements and tightens a workflow mutator edge case around setting a user task page when the BSON key is missing.
Changes:
- Add many new
mdl/visitor/*_test.gofiles that parse MDL snippets viaBuild(...)and assert resulting AST node fields. - Fix
mprWorkflowMutator.SetActivityProperty(..., "PAGE", ...)to handle missingTaskPagekeys by appending the field and replacing the activity in the workflow BSON tree. - Expand executor registry completeness coverage (new statement types + handler count snapshot) and apply minor formatting/cleanup in existing tests and backend code.
Reviewed changes
Copilot reviewed 28 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| mdl/visitor/visitor_widgets_test.go | New visitor tests for UPDATE WIDGETS statements. |
| mdl/visitor/visitor_settings_test.go | New visitor tests for settings/configuration statements. |
| mdl/visitor/visitor_security_test.go | New visitor tests for roles, grants/revokes, and project security statements. |
| mdl/visitor/visitor_rest_test.go | New visitor tests for REST client and published REST service statements. |
| mdl/visitor/visitor_odata_test.go | New visitor tests for OData client/service and external entity statements. |
| mdl/visitor/visitor_navigation_test.go | New visitor tests for navigation/profile/menu parsing. |
| mdl/visitor/visitor_move_test.go | New visitor tests for MOVE statements. |
| mdl/visitor/visitor_module_test.go | New visitor tests for CREATE MODULE. |
| mdl/visitor/visitor_misc_test.go | New visitor tests for misc statements (SEARCH/EXECUTE/help/UPDATE). |
| mdl/visitor/visitor_lint_test.go | New visitor tests for LINT and SHOW LINT RULES parsing. |
| mdl/visitor/visitor_jsonstructure_test.go | New visitor tests for CREATE JSON STRUCTURE. |
| mdl/visitor/visitor_import_mapping_test.go | New visitor tests for CREATE IMPORT MAPPING. |
| mdl/visitor/visitor_imagecollection_test.go | New visitor tests for CREATE IMAGE COLLECTION. |
| mdl/visitor/visitor_export_mapping_test.go | New visitor tests for CREATE EXPORT MAPPING. |
| mdl/visitor/visitor_enumeration_test.go | New visitor tests for enumeration ops and CREATE CONSTANT variants. |
| mdl/visitor/visitor_dbconnection_test.go | New visitor tests for CREATE DATABASE CONNECTION. |
| mdl/visitor/visitor_datatransformer_test.go | New visitor tests for CREATE DATA TRANSFORMER. |
| mdl/visitor/visitor_connection_test.go | New visitor tests for CONNECT/DISCONNECT. |
| mdl/visitor/visitor_businessevents_test.go | New visitor tests for business event service parsing. |
| mdl/visitor/visitor_association_test.go | New visitor tests for association create/alter parsing. |
| mdl/visitor/visitor_agenteditor_test.go | New visitor tests for agent editor-related statements (model/MCP/KB/agent). |
| mdl/types/id_test.go | Minor formatting alignment in ID validation tests. |
| mdl/types/edmx_test.go | Minor formatting alignment in EDMX tests. |
| mdl/executor/widget_registry.go | Minor formatting alignment in struct fields. |
| mdl/executor/registry_test.go | Add new known statement types + handler count snapshot test. |
| mdl/backend/mpr/workflow_mutator_test.go | Update/extend tests to cover PAGE mutation when TaskPage key is missing (incl. nested sub-flow). |
| mdl/backend/mpr/workflow_mutator.go | Fix PAGE mutation to handle missing TaskPage by appending + replacing activity in BSON tree. |
| mdl/backend/mpr/convert_roundtrip_test.go | Remove trailing whitespace line. |
| mdl/backend/mpr/backend.go | Formatting-only changes for method layout. |
| mdl/backend/mock/mock_workflow_mutator.go | Add a configurable mock implementation of backend.WorkflowMutator. |
| mdl/backend/mock/mock_page_mutator.go | Add a configurable mock implementation of backend.PageMutator. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…comment - visitor_lint_test.go: assert Target.Name and Target.Module separately to prevent false positives - visitor_widgets_test.go: use guarded type assertion with len check instead of direct assertion that would panic - mock_page_mutator.go: clarify doc comment that ContainerType defaults to ContainerPage, not zero value
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 31 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AI Code ReviewCritical IssuesNone found. Moderate IssuesNone found. Minor Issues
What Looks Good
RecommendationApprove. The PR significantly improves test coverage for the visitor package (from 22.8% to ~49% based on context) with high-quality tests. The minor formatting issues are trivial and the stacked PR context is justified. Once rebased, only the valuable visitor test changes will remain. Prerequisite changes (workflow fix, test enablers) are correct and ready for merging. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 31 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace 13 unguarded prog.Statements[0].(*ast.XxxStmt) direct assertions with guarded two-value form + t.Fatalf across visitor_settings_test.go, visitor_security_test.go, and visitor_lint_test.go to prevent panics on unexpected types.
AI Code ReviewWhat Looks Good
Minor Issues
RecommendationApprove. The PR substantially improves test coverage for the visitor package, fixes a real BSON handling issue, and adds useful testing utilities. The minor issues noted are acceptable in test code and don't affect correctness. The changes are well-scoped and follow project conventions. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 31 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.
Review: PR #245 — test: add visitor tests for 20 untested source filesVerdict: Approve with notes — excellent coverage investment. 69 new tests across 21 files is a meaningful step up from 22.8% visitor coverage. A few specific items worth addressing. OverviewPure test coverage PR. All new production changes (workflow mutator fix, mock mutators, registry completeness) are carry-overs from #243 and #244 in the stack — not re-reviewed here. The 69 new test functions follow the established visitor test pattern: inline MDL → Specific Issues1.
input := `... ToolChoice: auto, ...`
...
if stmt.ToolChoice != "auto" {The BSON schema (per the proposal, and confirmed by Tina's corrections in PR #214) stores 2. The test only covers 3. Constants test placed in enumeration file
Test Quality
Minor
|
Summary
Additional changes
This PR also includes changes from earlier PRs in the stack that this branch builds on:
SetActivityProperty(..., "PAGE", ...)to handle missingTaskPageBSON key by appending the field and replacing the activity in the workflow tree. IncludesreplaceActivityRecursivehelper for nested sub-flow traversal.MockPageMutatorandMockWorkflowMutatorconfigurable mock implementations. Expand executor registry completeness test with handler count snapshot.These are included because this is a stacked PR branch (PR 0 → A → B). Once the earlier PRs merge and this branch is rebased, only the visitor test changes will remain in the diff.
Motivation
Part of the MDL subsystem test coverage initiative. The visitor package had 22.8% coverage (18/79 exported functions tested). This PR covers the remaining untested visitor functions to provide a safety net for future refactoring.
Test approach
Follows existing visitor test pattern: inline MDL strings →
Build(input)→ type-assert AST nodes → assert key fields. Flat imperative style matchingvisitor_workflow_test.goconventions.