Skip to content

Commit fc7adcd

Browse files
committed
feat: add comprehensive mock-based handler tests (189 tests, 33 files)
Phase 1-8: 85 read/write handler tests with mock backend infrastructure Phase 9: 104 additional tests covering error paths, not-connected guards, and JSON format output Test categories: - Read-path handlers (SHOW/DESCRIBE) across 20+ domains - Write-path handlers (CREATE/DROP) for 10 operations - Backend error propagation for all handler groups - Not-connected guard verification for 29 guarded handlers - JSON format output validation for 26 show/list handlers
1 parent 24574fd commit fc7adcd

39 files changed

Lines changed: 3948 additions & 162 deletions

internal/marketplace/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var BaseURL = "https://marketplace-api.mendix.com"
1818
type Content struct {
1919
ContentID int `json:"contentId"`
2020
Publisher string `json:"publisher"`
21-
Type string `json:"type"` // "Module", "Widget", "Theme", "Starter App", ...
21+
Type string `json:"type"` // "Module", "Widget", "Theme", "Starter App", ...
2222
Categories []Category `json:"categories"`
2323
SupportCategory string `json:"supportCategory"` // "Platform", "Community", "Deprecated", ...
2424
LicenseURL string `json:"licenseUrl,omitempty"`

mdl/ast/ast_agenteditor.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ package ast
1616
// [, DeepLinkURL: '...']
1717
// );
1818
type CreateModelStmt struct {
19-
Name QualifiedName
20-
Documentation string
21-
Provider string // "MxCloudGenAI" by default
22-
Key *QualifiedName // qualified name of the String constant holding the Portal key
23-
DisplayName string // optional Portal-populated metadata
24-
KeyName string // optional Portal-populated metadata
25-
KeyID string // optional Portal-populated metadata
26-
Environment string // optional Portal-populated metadata
27-
ResourceName string // optional Portal-populated metadata
28-
DeepLinkURL string // optional Portal-populated metadata
19+
Name QualifiedName
20+
Documentation string
21+
Provider string // "MxCloudGenAI" by default
22+
Key *QualifiedName // qualified name of the String constant holding the Portal key
23+
DisplayName string // optional Portal-populated metadata
24+
KeyName string // optional Portal-populated metadata
25+
KeyID string // optional Portal-populated metadata
26+
Environment string // optional Portal-populated metadata
27+
ResourceName string // optional Portal-populated metadata
28+
DeepLinkURL string // optional Portal-populated metadata
2929
}
3030

3131
func (s *CreateModelStmt) isStatement() {}
@@ -93,21 +93,21 @@ func (s *DropKnowledgeBaseStmt) isStatement() {}
9393

9494
// CreateAgentStmt represents CREATE AGENT Module.Name (...) [{ body }].
9595
type CreateAgentStmt struct {
96-
Name QualifiedName
96+
Name QualifiedName
9797
Documentation string
98-
UsageType string // "Task" or "Conversational"
99-
Description string
100-
Model *QualifiedName // reference to a Model document
101-
Entity *QualifiedName // reference to a domain entity
102-
MaxTokens *int
103-
ToolChoice string
104-
Temperature *float64
105-
TopP *float64
106-
SystemPrompt string
107-
UserPrompt string
108-
Variables []AgentVarDef
109-
Tools []AgentToolDef
110-
KBTools []AgentKBToolDef
98+
UsageType string // "Task" or "Conversational"
99+
Description string
100+
Model *QualifiedName // reference to a Model document
101+
Entity *QualifiedName // reference to a domain entity
102+
MaxTokens *int
103+
ToolChoice string
104+
Temperature *float64
105+
TopP *float64
106+
SystemPrompt string
107+
UserPrompt string
108+
Variables []AgentVarDef
109+
Tools []AgentToolDef
110+
KBTools []AgentKBToolDef
111111
}
112112

113113
func (s *CreateAgentStmt) isStatement() {}
@@ -136,10 +136,10 @@ type AgentToolDef struct {
136136

137137
// AgentKBToolDef represents a KNOWLEDGE BASE block in CREATE AGENT body.
138138
type AgentKBToolDef struct {
139-
Name string // per-agent identifier
140-
Source *QualifiedName
141-
Collection string
142-
MaxResults int
143-
Description string
144-
Enabled bool
139+
Name string // per-agent identifier
140+
Source *QualifiedName
141+
Collection string
142+
MaxResults int
143+
Description string
144+
Enabled bool
145145
}

mdl/backend/mock/backend.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,16 @@ type MockBackend struct {
260260
FindAllCustomWidgetTypesFunc func(widgetID string) ([]*mpr.RawCustomWidgetType, error)
261261

262262
// AgentEditorBackend
263-
ListAgentEditorModelsFunc func() ([]*agenteditor.Model, error)
264-
ListAgentEditorKnowledgeBasesFunc func() ([]*agenteditor.KnowledgeBase, error)
265-
ListAgentEditorConsumedMCPServicesFunc func() ([]*agenteditor.ConsumedMCPService, error)
266-
ListAgentEditorAgentsFunc func() ([]*agenteditor.Agent, error)
263+
ListAgentEditorModelsFunc func() ([]*agenteditor.Model, error)
264+
ListAgentEditorKnowledgeBasesFunc func() ([]*agenteditor.KnowledgeBase, error)
265+
ListAgentEditorConsumedMCPServicesFunc func() ([]*agenteditor.ConsumedMCPService, error)
266+
ListAgentEditorAgentsFunc func() ([]*agenteditor.Agent, error)
267+
CreateAgentEditorModelFunc func(m *agenteditor.Model) error
268+
DeleteAgentEditorModelFunc func(id string) error
269+
CreateAgentEditorKnowledgeBaseFunc func(kb *agenteditor.KnowledgeBase) error
270+
DeleteAgentEditorKnowledgeBaseFunc func(id string) error
271+
CreateAgentEditorConsumedMCPServiceFunc func(svc *agenteditor.ConsumedMCPService) error
272+
DeleteAgentEditorConsumedMCPServiceFunc func(id string) error
273+
CreateAgentEditorAgentFunc func(a *agenteditor.Agent) error
274+
DeleteAgentEditorAgentFunc func(id string) error
267275
}

mdl/backend/mock/mock_infrastructure.go

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,58 @@ func (m *MockBackend) ListAgentEditorAgents() ([]*agenteditor.Agent, error) {
188188
return nil, nil
189189
}
190190

191-
func (m *MockBackend) CreateAgentEditorModel(_ *agenteditor.Model) error { return nil }
192-
func (m *MockBackend) DeleteAgentEditorModel(_ string) error { return nil }
193-
func (m *MockBackend) CreateAgentEditorKnowledgeBase(_ *agenteditor.KnowledgeBase) error { return nil }
194-
func (m *MockBackend) DeleteAgentEditorKnowledgeBase(_ string) error { return nil }
195-
func (m *MockBackend) CreateAgentEditorConsumedMCPService(_ *agenteditor.ConsumedMCPService) error {
191+
func (m *MockBackend) CreateAgentEditorModel(model *agenteditor.Model) error {
192+
if m.CreateAgentEditorModelFunc != nil {
193+
return m.CreateAgentEditorModelFunc(model)
194+
}
195+
return nil
196+
}
197+
198+
func (m *MockBackend) DeleteAgentEditorModel(id string) error {
199+
if m.DeleteAgentEditorModelFunc != nil {
200+
return m.DeleteAgentEditorModelFunc(id)
201+
}
202+
return nil
203+
}
204+
205+
func (m *MockBackend) CreateAgentEditorKnowledgeBase(kb *agenteditor.KnowledgeBase) error {
206+
if m.CreateAgentEditorKnowledgeBaseFunc != nil {
207+
return m.CreateAgentEditorKnowledgeBaseFunc(kb)
208+
}
209+
return nil
210+
}
211+
212+
func (m *MockBackend) DeleteAgentEditorKnowledgeBase(id string) error {
213+
if m.DeleteAgentEditorKnowledgeBaseFunc != nil {
214+
return m.DeleteAgentEditorKnowledgeBaseFunc(id)
215+
}
216+
return nil
217+
}
218+
219+
func (m *MockBackend) CreateAgentEditorConsumedMCPService(svc *agenteditor.ConsumedMCPService) error {
220+
if m.CreateAgentEditorConsumedMCPServiceFunc != nil {
221+
return m.CreateAgentEditorConsumedMCPServiceFunc(svc)
222+
}
223+
return nil
224+
}
225+
226+
func (m *MockBackend) DeleteAgentEditorConsumedMCPService(id string) error {
227+
if m.DeleteAgentEditorConsumedMCPServiceFunc != nil {
228+
return m.DeleteAgentEditorConsumedMCPServiceFunc(id)
229+
}
230+
return nil
231+
}
232+
233+
func (m *MockBackend) CreateAgentEditorAgent(a *agenteditor.Agent) error {
234+
if m.CreateAgentEditorAgentFunc != nil {
235+
return m.CreateAgentEditorAgentFunc(a)
236+
}
237+
return nil
238+
}
239+
240+
func (m *MockBackend) DeleteAgentEditorAgent(id string) error {
241+
if m.DeleteAgentEditorAgentFunc != nil {
242+
return m.DeleteAgentEditorAgentFunc(id)
243+
}
196244
return nil
197245
}
198-
func (m *MockBackend) DeleteAgentEditorConsumedMCPService(_ string) error { return nil }
199-
func (m *MockBackend) CreateAgentEditorAgent(_ *agenteditor.Agent) error { return nil }
200-
func (m *MockBackend) DeleteAgentEditorAgent(_ string) error { return nil }

0 commit comments

Comments
 (0)