-
Notifications
You must be signed in to change notification settings - Fork 21
test: add visitor tests for 20 untested source files #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
retran
wants to merge
11
commits into
mendixlabs:main
Choose a base branch
from
retran:test/visitor-coverage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,374
−27
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a640309
fix: handle missing TaskPage key in workflow activity mutation
retran 7047e58
test: add nested sub-flow test for replaceActivity recursive path
retran 767b9f8
test: use distinct IDs in nested sub-flow test to ensure recursive path
retran cddd422
refactor: use dGetArrayElements in replaceActivityRecursive to reduce…
retran 34d7a58
style: invert dSet condition to eliminate empty branch
retran d52a43c
Add MockPageMutator, MockWorkflowMutator, and fix registry completene…
retran 4d970a6
Clarify handler count snapshot test comment per review
retran ad2c0e5
test: add visitor tests for 20 untested visitor source files
retran 8a43c78
Address Copilot review: precise assertions, guarded type checks, fix …
retran 94891e8
Remove unused grantRevokeTest struct per review
retran a0e2a1c
Guard all type assertions in visitor tests with ok check
retran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package mock | ||
|
|
||
| import ( | ||
| "github.com/mendixlabs/mxcli/mdl/backend" | ||
| "github.com/mendixlabs/mxcli/model" | ||
| "github.com/mendixlabs/mxcli/sdk/pages" | ||
| ) | ||
|
|
||
| var _ backend.PageMutator = (*MockPageMutator)(nil) | ||
|
|
||
| // MockPageMutator implements backend.PageMutator. Every interface method is | ||
| // backed by a public function field. If the field is nil the method returns | ||
| // nil error (never panics). ContainerType defaults to ContainerPage when unset; | ||
| // all other methods return zero values. | ||
| type MockPageMutator struct { | ||
| ContainerTypeFunc func() backend.ContainerKind | ||
| SetWidgetPropertyFunc func(widgetRef string, prop string, value any) error | ||
| SetWidgetDataSourceFunc func(widgetRef string, ds pages.DataSource) error | ||
| SetColumnPropertyFunc func(gridRef string, columnRef string, prop string, value any) error | ||
| InsertWidgetFunc func(widgetRef string, columnRef string, position backend.InsertPosition, widgets []pages.Widget) error | ||
| DropWidgetFunc func(refs []backend.WidgetRef) error | ||
| ReplaceWidgetFunc func(widgetRef string, columnRef string, widgets []pages.Widget) error | ||
| FindWidgetFunc func(name string) bool | ||
| AddVariableFunc func(name, dataType, defaultValue string) error | ||
| DropVariableFunc func(name string) error | ||
| SetLayoutFunc func(newLayout string, paramMappings map[string]string) error | ||
| SetPluggablePropertyFunc func(widgetRef string, propKey string, op backend.PluggablePropertyOp, ctx backend.PluggablePropertyContext) error | ||
| EnclosingEntityFunc func(widgetRef string) string | ||
| WidgetScopeFunc func() map[string]model.ID | ||
| ParamScopeFunc func() (map[string]model.ID, map[string]string) | ||
| SaveFunc func() error | ||
| } | ||
|
|
||
| func (m *MockPageMutator) ContainerType() backend.ContainerKind { | ||
| if m.ContainerTypeFunc != nil { | ||
| return m.ContainerTypeFunc() | ||
| } | ||
| return backend.ContainerPage | ||
| } | ||
|
|
||
| func (m *MockPageMutator) SetWidgetProperty(widgetRef string, prop string, value any) error { | ||
| if m.SetWidgetPropertyFunc != nil { | ||
| return m.SetWidgetPropertyFunc(widgetRef, prop, value) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) SetWidgetDataSource(widgetRef string, ds pages.DataSource) error { | ||
| if m.SetWidgetDataSourceFunc != nil { | ||
| return m.SetWidgetDataSourceFunc(widgetRef, ds) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) SetColumnProperty(gridRef string, columnRef string, prop string, value any) error { | ||
| if m.SetColumnPropertyFunc != nil { | ||
| return m.SetColumnPropertyFunc(gridRef, columnRef, prop, value) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) InsertWidget(widgetRef string, columnRef string, position backend.InsertPosition, widgets []pages.Widget) error { | ||
| if m.InsertWidgetFunc != nil { | ||
| return m.InsertWidgetFunc(widgetRef, columnRef, position, widgets) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) DropWidget(refs []backend.WidgetRef) error { | ||
| if m.DropWidgetFunc != nil { | ||
| return m.DropWidgetFunc(refs) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) ReplaceWidget(widgetRef string, columnRef string, widgets []pages.Widget) error { | ||
| if m.ReplaceWidgetFunc != nil { | ||
| return m.ReplaceWidgetFunc(widgetRef, columnRef, widgets) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) FindWidget(name string) bool { | ||
| if m.FindWidgetFunc != nil { | ||
| return m.FindWidgetFunc(name) | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| func (m *MockPageMutator) AddVariable(name, dataType, defaultValue string) error { | ||
| if m.AddVariableFunc != nil { | ||
| return m.AddVariableFunc(name, dataType, defaultValue) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) DropVariable(name string) error { | ||
| if m.DropVariableFunc != nil { | ||
| return m.DropVariableFunc(name) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) SetLayout(newLayout string, paramMappings map[string]string) error { | ||
| if m.SetLayoutFunc != nil { | ||
| return m.SetLayoutFunc(newLayout, paramMappings) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) SetPluggableProperty(widgetRef string, propKey string, op backend.PluggablePropertyOp, ctx backend.PluggablePropertyContext) error { | ||
| if m.SetPluggablePropertyFunc != nil { | ||
| return m.SetPluggablePropertyFunc(widgetRef, propKey, op, ctx) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) EnclosingEntity(widgetRef string) string { | ||
| if m.EnclosingEntityFunc != nil { | ||
| return m.EnclosingEntityFunc(widgetRef) | ||
| } | ||
| return "" | ||
| } | ||
|
|
||
| func (m *MockPageMutator) WidgetScope() map[string]model.ID { | ||
| if m.WidgetScopeFunc != nil { | ||
| return m.WidgetScopeFunc() | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) ParamScope() (map[string]model.ID, map[string]string) { | ||
| if m.ParamScopeFunc != nil { | ||
| return m.ParamScopeFunc() | ||
| } | ||
| return nil, nil | ||
| } | ||
|
|
||
| func (m *MockPageMutator) Save() error { | ||
| if m.SaveFunc != nil { | ||
| return m.SaveFunc() | ||
| } | ||
| return nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package mock | ||
|
|
||
| import ( | ||
| "github.com/mendixlabs/mxcli/mdl/backend" | ||
| "github.com/mendixlabs/mxcli/sdk/workflows" | ||
| ) | ||
|
|
||
| var _ backend.WorkflowMutator = (*MockWorkflowMutator)(nil) | ||
|
|
||
| // MockWorkflowMutator implements backend.WorkflowMutator. Every interface | ||
| // method is backed by a public function field. If the field is nil the | ||
| // method returns zero values / nil error (never panics). | ||
| type MockWorkflowMutator struct { | ||
| SetPropertyFunc func(prop string, value string) error | ||
| SetPropertyWithEntityFunc func(prop string, value string, entity string) error | ||
| SetActivityPropertyFunc func(activityRef string, atPos int, prop string, value string) error | ||
| InsertAfterActivityFunc func(activityRef string, atPos int, activities []workflows.WorkflowActivity) error | ||
| DropActivityFunc func(activityRef string, atPos int) error | ||
| ReplaceActivityFunc func(activityRef string, atPos int, activities []workflows.WorkflowActivity) error | ||
| InsertOutcomeFunc func(activityRef string, atPos int, outcomeName string, activities []workflows.WorkflowActivity) error | ||
| DropOutcomeFunc func(activityRef string, atPos int, outcomeName string) error | ||
| InsertPathFunc func(activityRef string, atPos int, pathCaption string, activities []workflows.WorkflowActivity) error | ||
| DropPathFunc func(activityRef string, atPos int, pathCaption string) error | ||
| InsertBranchFunc func(activityRef string, atPos int, condition string, activities []workflows.WorkflowActivity) error | ||
| DropBranchFunc func(activityRef string, atPos int, branchName string) error | ||
| InsertBoundaryEventFunc func(activityRef string, atPos int, eventType string, delay string, activities []workflows.WorkflowActivity) error | ||
| DropBoundaryEventFunc func(activityRef string, atPos int) error | ||
| SaveFunc func() error | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) SetProperty(prop string, value string) error { | ||
| if m.SetPropertyFunc != nil { | ||
| return m.SetPropertyFunc(prop, value) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) SetPropertyWithEntity(prop string, value string, entity string) error { | ||
| if m.SetPropertyWithEntityFunc != nil { | ||
| return m.SetPropertyWithEntityFunc(prop, value, entity) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) SetActivityProperty(activityRef string, atPos int, prop string, value string) error { | ||
| if m.SetActivityPropertyFunc != nil { | ||
| return m.SetActivityPropertyFunc(activityRef, atPos, prop, value) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) InsertAfterActivity(activityRef string, atPos int, activities []workflows.WorkflowActivity) error { | ||
| if m.InsertAfterActivityFunc != nil { | ||
| return m.InsertAfterActivityFunc(activityRef, atPos, activities) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) DropActivity(activityRef string, atPos int) error { | ||
| if m.DropActivityFunc != nil { | ||
| return m.DropActivityFunc(activityRef, atPos) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) ReplaceActivity(activityRef string, atPos int, activities []workflows.WorkflowActivity) error { | ||
| if m.ReplaceActivityFunc != nil { | ||
| return m.ReplaceActivityFunc(activityRef, atPos, activities) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) InsertOutcome(activityRef string, atPos int, outcomeName string, activities []workflows.WorkflowActivity) error { | ||
| if m.InsertOutcomeFunc != nil { | ||
| return m.InsertOutcomeFunc(activityRef, atPos, outcomeName, activities) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) DropOutcome(activityRef string, atPos int, outcomeName string) error { | ||
| if m.DropOutcomeFunc != nil { | ||
| return m.DropOutcomeFunc(activityRef, atPos, outcomeName) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) InsertPath(activityRef string, atPos int, pathCaption string, activities []workflows.WorkflowActivity) error { | ||
| if m.InsertPathFunc != nil { | ||
| return m.InsertPathFunc(activityRef, atPos, pathCaption, activities) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) DropPath(activityRef string, atPos int, pathCaption string) error { | ||
| if m.DropPathFunc != nil { | ||
| return m.DropPathFunc(activityRef, atPos, pathCaption) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) InsertBranch(activityRef string, atPos int, condition string, activities []workflows.WorkflowActivity) error { | ||
| if m.InsertBranchFunc != nil { | ||
| return m.InsertBranchFunc(activityRef, atPos, condition, activities) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) DropBranch(activityRef string, atPos int, branchName string) error { | ||
| if m.DropBranchFunc != nil { | ||
| return m.DropBranchFunc(activityRef, atPos, branchName) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) InsertBoundaryEvent(activityRef string, atPos int, eventType string, delay string, activities []workflows.WorkflowActivity) error { | ||
| if m.InsertBoundaryEventFunc != nil { | ||
| return m.InsertBoundaryEventFunc(activityRef, atPos, eventType, delay, activities) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) DropBoundaryEvent(activityRef string, atPos int) error { | ||
| if m.DropBoundaryEventFunc != nil { | ||
| return m.DropBoundaryEventFunc(activityRef, atPos) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (m *MockWorkflowMutator) Save() error { | ||
| if m.SaveFunc != nil { | ||
| return m.SaveFunc() | ||
| } | ||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.