Documentation
¶
Index ¶
- type LogMessage
- type MockAgentProvider
- func (m *MockAgentProvider) Clear()
- func (m *MockAgentProvider) Execute(ctx context.Context, prompt string, options map[string]any) (*workflow.AgentResult, error)
- func (m *MockAgentProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, ...) (*workflow.ConversationResult, error)
- func (m *MockAgentProvider) Name() string
- func (m *MockAgentProvider) SetConversationFunc(...)
- func (m *MockAgentProvider) SetExecuteFunc(...)
- func (m *MockAgentProvider) SetValidateFunc(f func() error)
- func (m *MockAgentProvider) Validate() error
- type MockAgentRegistry
- type MockAuditTrailWriter
- func (m *MockAuditTrailWriter) Clear()
- func (m *MockAuditTrailWriter) Close() error
- func (m *MockAuditTrailWriter) GetEvents() []workflow.AuditEvent
- func (m *MockAuditTrailWriter) IsClosed() bool
- func (m *MockAuditTrailWriter) SetCloseError(err error)
- func (m *MockAuditTrailWriter) SetWriteError(err error)
- func (m *MockAuditTrailWriter) Write(ctx context.Context, event *workflow.AuditEvent) error
- type MockCLICall
- type MockCLIExecutor
- func (m *MockCLIExecutor) Clear()
- func (m *MockCLIExecutor) GetCalls() []MockCLICall
- func (m *MockCLIExecutor) Run(ctx context.Context, name string, args ...string) (stdout, stderr []byte, err error)
- func (m *MockCLIExecutor) SetError(err error)
- func (m *MockCLIExecutor) SetOutput(stdout, stderr []byte)
- type MockCommandExecutor
- func (m *MockCommandExecutor) Clear()
- func (m *MockCommandExecutor) Execute(ctx context.Context, cmd *ports.Command) (*ports.CommandResult, error)
- func (m *MockCommandExecutor) GetCalls() []*ports.Command
- func (m *MockCommandExecutor) SetCommandResult(cmd string, result *ports.CommandResult)
- func (m *MockCommandExecutor) SetExecuteError(err error)
- func (m *MockCommandExecutor) SetResult(result *ports.CommandResult)deprecated
- type MockErrorFormatter
- func (m *MockErrorFormatter) AddHintGenerator(gen domainerrors.HintGenerator)
- func (m *MockErrorFormatter) Clear()
- func (m *MockErrorFormatter) EnableHints(enabled bool)
- func (m *MockErrorFormatter) FormatError(err *domainerrors.StructuredError) string
- func (m *MockErrorFormatter) GetHints(err *domainerrors.StructuredError) []domainerrors.Hint
- func (m *MockErrorFormatter) SetFormatFunc(fn func(err *domainerrors.StructuredError) string)
- func (m *MockErrorFormatter) SetHintGenerators(generators []domainerrors.HintGenerator)
- type MockExpressionEvaluator
- func (m *MockExpressionEvaluator) Clear()
- func (m *MockExpressionEvaluator) EvaluateBool(expr string, ctx *interpolation.Context) (bool, error)
- func (m *MockExpressionEvaluator) EvaluateInt(expr string, ctx *interpolation.Context) (int, error)
- func (m *MockExpressionEvaluator) SetBoolResult(result bool, err error)
- func (m *MockExpressionEvaluator) SetEvaluateBoolFunc(fn func(string, *interpolation.Context) (bool, error))
- func (m *MockExpressionEvaluator) SetEvaluateIntFunc(fn func(string, *interpolation.Context) (int, error))
- func (m *MockExpressionEvaluator) SetIntResult(result int, err error)
- type MockExpressionValidator
- type MockHistoryStore
- func (m *MockHistoryStore) Cleanup(ctx context.Context, olderThan time.Duration) (int, error)
- func (m *MockHistoryStore) Close() error
- func (m *MockHistoryStore) GetStats(ctx context.Context, filter *workflow.HistoryFilter) (*workflow.HistoryStats, error)
- func (m *MockHistoryStore) List(ctx context.Context, filter *workflow.HistoryFilter) ([]*workflow.ExecutionRecord, error)
- func (m *MockHistoryStore) Record(ctx context.Context, record *workflow.ExecutionRecord) error
- type MockLogger
- func (m *MockLogger) Clear()
- func (m *MockLogger) Debug(msg string, fields ...any)
- func (m *MockLogger) Error(msg string, fields ...any)
- func (m *MockLogger) GetMessages() []LogMessage
- func (m *MockLogger) GetMessagesByLevel(level string) []LogMessage
- func (m *MockLogger) Info(msg string, fields ...any)
- func (m *MockLogger) Warn(msg string, fields ...any)
- func (m *MockLogger) WithContext(ctx map[string]any) ports.Logger
- type MockPluginConfig
- func (m *MockPluginConfig) GetConfig(name string) map[string]any
- func (m *MockPluginConfig) IsEnabled(name string) bool
- func (m *MockPluginConfig) SetConfig(ctx context.Context, name string, config map[string]any) error
- func (m *MockPluginConfig) SetEnabled(ctx context.Context, name string, enabled bool) error
- type MockPluginManager
- func (m *MockPluginManager) AddPlugin(name string, status pluginmodel.PluginStatus) *pluginmodel.PluginInfo
- func (m *MockPluginManager) Clear()
- func (m *MockPluginManager) Discover(ctx context.Context) ([]*pluginmodel.PluginInfo, error)
- func (m *MockPluginManager) Get(name string) (*pluginmodel.PluginInfo, bool)
- func (m *MockPluginManager) Init(ctx context.Context, name string, config map[string]any) error
- func (m *MockPluginManager) List() []*pluginmodel.PluginInfo
- func (m *MockPluginManager) Load(ctx context.Context, name string) error
- func (m *MockPluginManager) SetDiscoverFunc(fn func(ctx context.Context) ([]*pluginmodel.PluginInfo, error))
- func (m *MockPluginManager) SetInitFunc(fn func(ctx context.Context, name string, config map[string]any) error)
- func (m *MockPluginManager) SetLoadFunc(fn func(ctx context.Context, name string) error)
- func (m *MockPluginManager) SetShutdownError(err error)
- func (m *MockPluginManager) SetShutdownFunc(fn func(ctx context.Context, name string) error)
- func (m *MockPluginManager) Shutdown(ctx context.Context, name string) error
- func (m *MockPluginManager) ShutdownAll(ctx context.Context) error
- type MockPluginStateStore
- type MockPluginStore
- type MockStateStore
- func (m *MockStateStore) Clear()
- func (m *MockStateStore) Delete(ctx context.Context, workflowID string) error
- func (m *MockStateStore) List(ctx context.Context) ([]string, error)
- func (m *MockStateStore) Load(ctx context.Context, workflowID string) (*workflow.ExecutionContext, error)
- func (m *MockStateStore) Save(ctx context.Context, state *workflow.ExecutionContext) error
- func (m *MockStateStore) SetDeleteError(err error)
- func (m *MockStateStore) SetListError(err error)
- func (m *MockStateStore) SetLoadError(err error)
- func (m *MockStateStore) SetSaveError(err error)
- type MockTemplateRepository
- func (m *MockTemplateRepository) AddTemplate(name string, tpl *workflow.Template)
- func (m *MockTemplateRepository) Clear()
- func (m *MockTemplateRepository) Exists(ctx context.Context, name string) bool
- func (m *MockTemplateRepository) GetTemplate(ctx context.Context, name string) (*workflow.Template, error)
- func (m *MockTemplateRepository) ListTemplates(ctx context.Context) ([]string, error)
- func (m *MockTemplateRepository) SetGetError(err error)
- func (m *MockTemplateRepository) SetListError(err error)
- type MockWorkflowRepository
- func (m *MockWorkflowRepository) AddWorkflow(name string, wf *workflow.Workflow)
- func (m *MockWorkflowRepository) Clear()
- func (m *MockWorkflowRepository) Exists(ctx context.Context, name string) (bool, error)
- func (m *MockWorkflowRepository) List(ctx context.Context) ([]string, error)
- func (m *MockWorkflowRepository) Load(ctx context.Context, name string) (*workflow.Workflow, error)
- func (m *MockWorkflowRepository) SetExistsError(err error)
- func (m *MockWorkflowRepository) SetListError(err error)
- func (m *MockWorkflowRepository) SetLoadError(err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogMessage ¶
LogMessage represents a captured log message with level and content.
type MockAgentProvider ¶
type MockAgentProvider struct {
// contains filtered or unexported fields
}
MockAgentProvider is a thread-safe mock implementation of ports.AgentProvider. It uses sync.RWMutex to protect concurrent access to the mock state and callback functions.
Usage:
provider := testutil.NewMockAgentProvider("test-agent")
provider.SetExecuteFunc(func(ctx context.Context, prompt string, options map[string]any) (*workflow.AgentResult, error) {
return &workflow.AgentResult{
Provider: "test-agent",
Output: "mock response",
Tokens: 100,
}, nil
})
result, err := provider.Execute(ctx, "test prompt", nil)
func NewMockAgentProvider ¶
func NewMockAgentProvider(name string) *MockAgentProvider
NewMockAgentProvider creates a new thread-safe mock agent provider with the given name.
func (*MockAgentProvider) Clear ¶
func (m *MockAgentProvider) Clear()
Clear resets all callback functions (test helper). Thread-safe for concurrent access.
func (*MockAgentProvider) Execute ¶
func (m *MockAgentProvider) Execute(ctx context.Context, prompt string, options map[string]any) (*workflow.AgentResult, error)
Execute invokes the agent with the given prompt and options. Thread-safe for concurrent access. Returns a stub result if no executeFunc is configured.
func (*MockAgentProvider) ExecuteConversation ¶
func (m *MockAgentProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any) (*workflow.ConversationResult, error)
ExecuteConversation invokes the agent with conversation history for multi-turn interactions. Thread-safe for concurrent access. Returns a stub result if no conversationFunc is configured.
func (*MockAgentProvider) Name ¶
func (m *MockAgentProvider) Name() string
Name returns the provider identifier. Thread-safe for concurrent access.
func (*MockAgentProvider) SetConversationFunc ¶
func (m *MockAgentProvider) SetConversationFunc(f func(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any) (*workflow.ConversationResult, error))
SetConversationFunc sets the callback function for ExecuteConversation method (test helper). Thread-safe for concurrent access.
func (*MockAgentProvider) SetExecuteFunc ¶
func (m *MockAgentProvider) SetExecuteFunc(f func(ctx context.Context, prompt string, options map[string]any) (*workflow.AgentResult, error))
SetExecuteFunc sets the callback function for Execute method (test helper). Thread-safe for concurrent access.
func (*MockAgentProvider) SetValidateFunc ¶
func (m *MockAgentProvider) SetValidateFunc(f func() error)
SetValidateFunc sets the callback function for Validate method (test helper). Thread-safe for concurrent access.
func (*MockAgentProvider) Validate ¶
func (m *MockAgentProvider) Validate() error
Validate checks if the provider is properly configured and available. Thread-safe for concurrent access. Returns nil if no validateFunc is configured.
type MockAgentRegistry ¶
type MockAgentRegistry struct {
// contains filtered or unexported fields
}
MockAgentRegistry is a thread-safe mock implementation of ports.AgentRegistry. It uses sync.RWMutex to protect concurrent access to the providers map.
Usage:
registry := testutil.NewMockAgentRegistry()
provider := testutil.NewMockAgentProvider("test-agent")
registry.Register(provider)
p, err := registry.Get("test-agent")
func NewMockAgentRegistry ¶
func NewMockAgentRegistry() *MockAgentRegistry
NewMockAgentRegistry creates a new thread-safe mock agent registry.
func (*MockAgentRegistry) Clear ¶
func (m *MockAgentRegistry) Clear()
Clear removes all providers from the registry (test helper). Thread-safe for concurrent access.
func (*MockAgentRegistry) Get ¶
func (m *MockAgentRegistry) Get(name string) (ports.AgentProvider, error)
Get retrieves a provider by name. Thread-safe for concurrent access. Returns error if provider is not found.
func (*MockAgentRegistry) Has ¶
func (m *MockAgentRegistry) Has(name string) bool
Has checks if a provider with the given name is registered. Thread-safe for concurrent access.
func (*MockAgentRegistry) List ¶
func (m *MockAgentRegistry) List() []string
List returns all registered provider names. Thread-safe for concurrent access.
func (*MockAgentRegistry) Register ¶
func (m *MockAgentRegistry) Register(provider ports.AgentProvider) error
Register adds a provider to the registry. Thread-safe for concurrent access. Returns error if a provider with the same name already exists.
type MockAuditTrailWriter ¶
type MockAuditTrailWriter struct {
// contains filtered or unexported fields
}
MockAuditTrailWriter is a thread-safe mock implementation of ports.AuditTrailWriter. It uses sync.RWMutex to protect concurrent access to the events slice. Supports lifecycle state tracking (isClosed) for write-after-close and close-idempotency tests.
Usage:
writer := testutil.NewMockAuditTrailWriter() err := writer.Write(ctx, &event) events := writer.GetEvents()
func NewMockAuditTrailWriter ¶
func NewMockAuditTrailWriter() *MockAuditTrailWriter
NewMockAuditTrailWriter creates a new thread-safe mock audit trail writer.
func (*MockAuditTrailWriter) Clear ¶
func (m *MockAuditTrailWriter) Clear()
Clear removes all recorded events, resets errors, and reopens the writer (test helper). Thread-safe for concurrent access.
func (*MockAuditTrailWriter) Close ¶
func (m *MockAuditTrailWriter) Close() error
Close closes the writer. Returns error if already closed or closeErr is set. Thread-safe for concurrent access.
func (*MockAuditTrailWriter) GetEvents ¶
func (m *MockAuditTrailWriter) GetEvents() []workflow.AuditEvent
GetEvents returns all recorded audit events (test helper). Thread-safe for concurrent access.
func (*MockAuditTrailWriter) IsClosed ¶
func (m *MockAuditTrailWriter) IsClosed() bool
IsClosed returns whether the writer has been closed (test helper). Thread-safe for concurrent access.
func (*MockAuditTrailWriter) SetCloseError ¶
func (m *MockAuditTrailWriter) SetCloseError(err error)
SetCloseError configures the mock to return an error on Close calls (test helper). Thread-safe for concurrent access.
func (*MockAuditTrailWriter) SetWriteError ¶
func (m *MockAuditTrailWriter) SetWriteError(err error)
SetWriteError configures the mock to return an error on Write calls (test helper). Thread-safe for concurrent access.
func (*MockAuditTrailWriter) Write ¶
func (m *MockAuditTrailWriter) Write(ctx context.Context, event *workflow.AuditEvent) error
Write appends an audit event to the recorded events. Returns error if writer is closed or writeErr is set. Thread-safe for concurrent access.
type MockCLICall ¶
MockCLICall records a single CLI execution call.
type MockCLIExecutor ¶
type MockCLIExecutor struct {
// contains filtered or unexported fields
}
MockCLIExecutor is a thread-safe mock implementation of ports.CLIExecutor. It uses sync.Mutex to protect concurrent access to call history.
Usage:
executor := testutil.NewMockCLIExecutor()
executor.SetOutput([]byte("output"), []byte(""))
stdout, stderr, err := executor.Run(ctx, "claude", "--version")
func NewMockCLIExecutor ¶
func NewMockCLIExecutor() *MockCLIExecutor
NewMockCLIExecutor creates a new thread-safe mock CLI executor.
func (*MockCLIExecutor) Clear ¶
func (m *MockCLIExecutor) Clear()
Clear removes all recorded calls and resets output/errors (test helper).
func (*MockCLIExecutor) GetCalls ¶
func (m *MockCLIExecutor) GetCalls() []MockCLICall
GetCalls returns all recorded Run calls (test helper).
func (*MockCLIExecutor) Run ¶
func (m *MockCLIExecutor) Run(ctx context.Context, name string, args ...string) (stdout, stderr []byte, err error)
Run executes a binary and returns the configured output.
func (*MockCLIExecutor) SetError ¶
func (m *MockCLIExecutor) SetError(err error)
SetError configures the mock to return an error on Run calls (test helper).
func (*MockCLIExecutor) SetOutput ¶
func (m *MockCLIExecutor) SetOutput(stdout, stderr []byte)
SetOutput configures the mock to return specific stdout and stderr (test helper).
type MockCommandExecutor ¶
type MockCommandExecutor struct {
// contains filtered or unexported fields
}
MockCommandExecutor is a thread-safe mock implementation of ports.CommandExecutor. It uses sync.Mutex to protect concurrent access to call history.
Usage:
executor := testutil.NewMockCommandExecutor()
executor.SetResult(&ports.CommandResult{Stdout: "output", ExitCode: 0})
result, err := executor.Execute(ctx, cmd)
func NewMockCommandExecutor ¶
func NewMockCommandExecutor() *MockCommandExecutor
NewMockCommandExecutor creates a new thread-safe mock command executor.
func (*MockCommandExecutor) Clear ¶
func (m *MockCommandExecutor) Clear()
Clear removes all recorded calls and resets errors (test helper).
func (*MockCommandExecutor) Execute ¶
func (m *MockCommandExecutor) Execute(ctx context.Context, cmd *ports.Command) (*ports.CommandResult, error)
Execute runs a command and returns the result.
func (*MockCommandExecutor) GetCalls ¶
func (m *MockCommandExecutor) GetCalls() []*ports.Command
GetCalls returns all recorded Execute calls (test helper).
func (*MockCommandExecutor) SetCommandResult ¶
func (m *MockCommandExecutor) SetCommandResult(cmd string, result *ports.CommandResult)
SetCommandResult configures the mock to return a specific result for a given command (test helper).
func (*MockCommandExecutor) SetExecuteError ¶
func (m *MockCommandExecutor) SetExecuteError(err error)
SetExecuteError configures the mock to return an error on Execute calls (test helper).
func (*MockCommandExecutor) SetResult
deprecated
func (m *MockCommandExecutor) SetResult(result *ports.CommandResult)
SetResult configures the mock to return a specific result for all commands (test helper).
Deprecated: Use SetCommandResult for command-specific results. Migration tracked in #150.
type MockErrorFormatter ¶
type MockErrorFormatter struct {
// contains filtered or unexported fields
}
MockErrorFormatter is a thread-safe mock implementation of ports.ErrorFormatter. It uses sync.Mutex to protect concurrent access to the format function and hint generators.
C048 Extension: Now supports hint generators for testing hint-aware formatting behavior.
Usage:
formatter := testutil.NewMockErrorFormatter()
formatter.SetFormatFunc(func(err *domainerrors.StructuredError) string {
return fmt.Sprintf("[%s] %s", err.Code, err.Message)
})
formatter.AddHintGenerator(func(err *domainerrors.StructuredError) []domainerrors.Hint {
return []domainerrors.Hint{{Message: "Did you mean 'workflow.yaml'?"}}
})
output := formatter.FormatError(structuredErr)
func NewMockErrorFormatter ¶
func NewMockErrorFormatter() *MockErrorFormatter
NewMockErrorFormatter creates a new thread-safe mock error formatter. By default, hints are disabled (hintsEnabled=false) to maintain backward compatibility.
func (*MockErrorFormatter) AddHintGenerator ¶
func (m *MockErrorFormatter) AddHintGenerator(gen domainerrors.HintGenerator)
AddHintGenerator adds a hint generator to the mock formatter (test helper). Thread-safe for concurrent access. Useful for testing hint generation behavior without implementing full formatters.
func (*MockErrorFormatter) Clear ¶
func (m *MockErrorFormatter) Clear()
Clear resets the format function and hint generators (test helper). Thread-safe for concurrent access.
func (*MockErrorFormatter) EnableHints ¶
func (m *MockErrorFormatter) EnableHints(enabled bool)
EnableHints enables hint generation in the mock formatter (test helper). Thread-safe for concurrent access.
func (*MockErrorFormatter) FormatError ¶
func (m *MockErrorFormatter) FormatError(err *domainerrors.StructuredError) string
FormatError formats a structured error using the configured format function. Thread-safe for concurrent access. Returns empty string if no formatFunc is configured.
func (*MockErrorFormatter) GetHints ¶
func (m *MockErrorFormatter) GetHints(err *domainerrors.StructuredError) []domainerrors.Hint
GetHints returns all hints generated by registered generators for the given error (test helper). Thread-safe for concurrent access. Returns empty slice if hints are disabled or no generators are configured.
func (*MockErrorFormatter) SetFormatFunc ¶
func (m *MockErrorFormatter) SetFormatFunc(fn func(err *domainerrors.StructuredError) string)
SetFormatFunc configures a custom function for FormatError calls (test helper). Thread-safe for concurrent access.
func (*MockErrorFormatter) SetHintGenerators ¶
func (m *MockErrorFormatter) SetHintGenerators(generators []domainerrors.HintGenerator)
SetHintGenerators replaces all hint generators with the provided slice (test helper). Thread-safe for concurrent access.
type MockExpressionEvaluator ¶
type MockExpressionEvaluator struct {
// contains filtered or unexported fields
}
MockExpressionEvaluator is a thread-safe mock implementation of ports.ExpressionEvaluator. It uses sync.Mutex to protect concurrent access to configuration.
Usage:
evaluator := testutil.NewMockExpressionEvaluator()
evaluator.SetBoolResult(true, nil)
result, err := evaluator.EvaluateBool("inputs.count > 5", ctx)
func NewMockExpressionEvaluator ¶
func NewMockExpressionEvaluator() *MockExpressionEvaluator
NewMockExpressionEvaluator creates a new thread-safe mock expression evaluator.
func (*MockExpressionEvaluator) Clear ¶
func (m *MockExpressionEvaluator) Clear()
Clear resets the mock to default state (test helper).
func (*MockExpressionEvaluator) EvaluateBool ¶
func (m *MockExpressionEvaluator) EvaluateBool(expr string, ctx *interpolation.Context) (bool, error)
EvaluateBool evaluates a boolean expression against the provided context.
func (*MockExpressionEvaluator) EvaluateInt ¶
func (m *MockExpressionEvaluator) EvaluateInt(expr string, ctx *interpolation.Context) (int, error)
EvaluateInt evaluates an arithmetic expression against the provided context.
func (*MockExpressionEvaluator) SetBoolResult ¶
func (m *MockExpressionEvaluator) SetBoolResult(result bool, err error)
SetBoolResult configures the mock to return a specific result for EvaluateBool calls (test helper).
func (*MockExpressionEvaluator) SetEvaluateBoolFunc ¶
func (m *MockExpressionEvaluator) SetEvaluateBoolFunc(fn func(string, *interpolation.Context) (bool, error))
SetEvaluateBoolFunc configures a custom function to handle EvaluateBool calls (test helper).
func (*MockExpressionEvaluator) SetEvaluateIntFunc ¶
func (m *MockExpressionEvaluator) SetEvaluateIntFunc(fn func(string, *interpolation.Context) (int, error))
SetEvaluateIntFunc configures a custom function to handle EvaluateInt calls (test helper).
func (*MockExpressionEvaluator) SetIntResult ¶
func (m *MockExpressionEvaluator) SetIntResult(result int, err error)
SetIntResult configures the mock to return a specific result for EvaluateInt calls (test helper).
type MockExpressionValidator ¶
type MockExpressionValidator struct {
// contains filtered or unexported fields
}
MockExpressionValidator is a thread-safe mock implementation of ports.ExpressionValidator. It uses sync.Mutex to protect concurrent access to configuration.
Usage:
validator := testutil.NewMockExpressionValidator()
validator.SetCompileError(errors.New("syntax error"))
err := validator.Compile("invalid expression")
func NewMockExpressionValidator ¶
func NewMockExpressionValidator() *MockExpressionValidator
NewMockExpressionValidator creates a new thread-safe mock expression validator.
func (*MockExpressionValidator) Clear ¶
func (m *MockExpressionValidator) Clear()
Clear resets the mock to default state (test helper).
func (*MockExpressionValidator) Compile ¶
func (m *MockExpressionValidator) Compile(expression string) error
Compile validates the syntax of an expression string.
func (*MockExpressionValidator) SetCompileError ¶
func (m *MockExpressionValidator) SetCompileError(err error)
SetCompileError configures the mock to return an error on Compile calls (test helper).
func (*MockExpressionValidator) SetCompileFunc ¶
func (m *MockExpressionValidator) SetCompileFunc(fn func(string) error)
SetCompileFunc configures a custom function to handle Compile calls (test helper).
type MockHistoryStore ¶
type MockHistoryStore struct {
// contains filtered or unexported fields
}
MockHistoryStore is a thread-safe mock implementation of ports.HistoryStore. It uses sync.RWMutex to protect concurrent access to the records slice.
Usage:
store := testutil.NewMockHistoryStore()
store.Record(ctx, &workflow.ExecutionRecord{...})
records, _ := store.List(ctx, nil)
func NewMockHistoryStore ¶
func NewMockHistoryStore() *MockHistoryStore
NewMockHistoryStore creates a new thread-safe mock history store.
func (*MockHistoryStore) Cleanup ¶
Cleanup removes records older than the given duration (returns 0 in mock).
func (*MockHistoryStore) Close ¶
func (m *MockHistoryStore) Close() error
Close closes the store (no-op in mock).
func (*MockHistoryStore) GetStats ¶
func (m *MockHistoryStore) GetStats(ctx context.Context, filter *workflow.HistoryFilter) (*workflow.HistoryStats, error)
GetStats returns empty stats (not implemented in mock).
func (*MockHistoryStore) List ¶
func (m *MockHistoryStore) List(ctx context.Context, filter *workflow.HistoryFilter) ([]*workflow.ExecutionRecord, error)
List returns all recorded execution records (filter is ignored in mock).
func (*MockHistoryStore) Record ¶
func (m *MockHistoryStore) Record(ctx context.Context, record *workflow.ExecutionRecord) error
Record stores an execution record.
type MockLogger ¶
type MockLogger struct {
// contains filtered or unexported fields
}
MockLogger is a thread-safe mock implementation of ports.Logger. It uses sync.Mutex to protect concurrent access to captured messages.
Usage:
logger := testutil.NewMockLogger()
logger.Info("test message", "key", "value")
messages := logger.GetMessages()
func NewMockLogger ¶
func NewMockLogger() *MockLogger
NewMockLogger creates a new thread-safe mock logger.
func (*MockLogger) Clear ¶
func (m *MockLogger) Clear()
Clear removes all captured messages (test helper).
func (*MockLogger) Debug ¶
func (m *MockLogger) Debug(msg string, fields ...any)
Debug logs a debug message.
func (*MockLogger) Error ¶
func (m *MockLogger) Error(msg string, fields ...any)
Error logs an error message.
func (*MockLogger) GetMessages ¶
func (m *MockLogger) GetMessages() []LogMessage
GetMessages returns all captured log messages (test helper).
func (*MockLogger) GetMessagesByLevel ¶
func (m *MockLogger) GetMessagesByLevel(level string) []LogMessage
GetMessagesByLevel returns captured messages filtered by level (test helper).
func (*MockLogger) Info ¶
func (m *MockLogger) Info(msg string, fields ...any)
Info logs an info message.
func (*MockLogger) Warn ¶
func (m *MockLogger) Warn(msg string, fields ...any)
Warn logs a warning message.
func (*MockLogger) WithContext ¶
func (m *MockLogger) WithContext(ctx map[string]any) ports.Logger
WithContext returns a logger with additional context fields. Creates a new immutable logger instance with accumulated context.
type MockPluginConfig ¶
type MockPluginConfig struct {
SetEnabledErr error
SetConfigErr error
// contains filtered or unexported fields
}
MockPluginConfig is a thread-safe mock implementation of ports.PluginConfig. It supports optional error injection via SetEnabledErr and SetConfigErr fields.
func NewMockPluginConfig ¶
func NewMockPluginConfig() *MockPluginConfig
NewMockPluginConfig creates a new thread-safe mock plugin config.
func (*MockPluginConfig) GetConfig ¶
func (m *MockPluginConfig) GetConfig(name string) map[string]any
GetConfig returns the stored configuration for a plugin. Thread-safe for concurrent access.
func (*MockPluginConfig) IsEnabled ¶
func (m *MockPluginConfig) IsEnabled(name string) bool
IsEnabled returns whether a plugin is enabled. Unknown plugin names return true (default-enabled contract). Thread-safe for concurrent access.
func (*MockPluginConfig) SetConfig ¶
SetConfig stores configuration for a plugin. Returns SetConfigErr if set. Thread-safe for concurrent access.
func (*MockPluginConfig) SetEnabled ¶
SetEnabled enables or disables a plugin by name. Returns SetEnabledErr if set. Thread-safe for concurrent access.
type MockPluginManager ¶
type MockPluginManager struct {
// contains filtered or unexported fields
}
MockPluginManager is a thread-safe mock implementation of ports.PluginManager. It uses sync.RWMutex to protect concurrent access to the plugins map. This mock consolidates duplicate implementations from plugin_test.go and plugin_service_test.go.
Usage:
mgr := testutil.NewMockPluginManager()
mgr.AddPlugin("test-plugin", pluginmodel.StatusRunning)
info, found := mgr.Get("test-plugin")
func NewMockPluginManager ¶
func NewMockPluginManager() *MockPluginManager
NewMockPluginManager creates a new thread-safe mock plugin manager.
func (*MockPluginManager) AddPlugin ¶
func (m *MockPluginManager) AddPlugin(name string, status pluginmodel.PluginStatus) *pluginmodel.PluginInfo
AddPlugin adds or updates a plugin in the manager (test helper). Thread-safe for concurrent access.
func (*MockPluginManager) Clear ¶
func (m *MockPluginManager) Clear()
Clear removes all plugins and resets configuration (test helper). Thread-safe for concurrent access.
func (*MockPluginManager) Discover ¶
func (m *MockPluginManager) Discover(ctx context.Context) ([]*pluginmodel.PluginInfo, error)
Discover finds plugins in the plugins directory. Thread-safe for concurrent access.
func (*MockPluginManager) Get ¶
func (m *MockPluginManager) Get(name string) (*pluginmodel.PluginInfo, bool)
Get returns plugin info by name. Thread-safe for concurrent access.
func (*MockPluginManager) Init ¶
Init initializes a loaded plugin. Thread-safe for concurrent access.
func (*MockPluginManager) List ¶
func (m *MockPluginManager) List() []*pluginmodel.PluginInfo
List returns all known plugins. Thread-safe for concurrent access.
func (*MockPluginManager) Load ¶
func (m *MockPluginManager) Load(ctx context.Context, name string) error
Load loads a plugin by name. Thread-safe for concurrent access.
func (*MockPluginManager) SetDiscoverFunc ¶
func (m *MockPluginManager) SetDiscoverFunc(fn func(ctx context.Context) ([]*pluginmodel.PluginInfo, error))
SetDiscoverFunc configures a custom function for Discover calls (test helper). Thread-safe for concurrent access.
func (*MockPluginManager) SetInitFunc ¶
func (m *MockPluginManager) SetInitFunc(fn func(ctx context.Context, name string, config map[string]any) error)
SetInitFunc configures a custom function for Init calls (test helper). Thread-safe for concurrent access.
func (*MockPluginManager) SetLoadFunc ¶
func (m *MockPluginManager) SetLoadFunc(fn func(ctx context.Context, name string) error)
SetLoadFunc configures a custom function for Load calls (test helper). Thread-safe for concurrent access.
func (*MockPluginManager) SetShutdownError ¶
func (m *MockPluginManager) SetShutdownError(err error)
SetShutdownError configures an error to be returned by ShutdownAll (test helper). Thread-safe for concurrent access.
func (*MockPluginManager) SetShutdownFunc ¶
func (m *MockPluginManager) SetShutdownFunc(fn func(ctx context.Context, name string) error)
SetShutdownFunc configures a custom function for Shutdown calls (test helper). Thread-safe for concurrent access.
func (*MockPluginManager) Shutdown ¶
func (m *MockPluginManager) Shutdown(ctx context.Context, name string) error
Shutdown stops a running plugin. Thread-safe for concurrent access.
func (*MockPluginManager) ShutdownAll ¶
func (m *MockPluginManager) ShutdownAll(ctx context.Context) error
ShutdownAll stops all running plugins. Thread-safe for concurrent access.
type MockPluginStateStore ¶
type MockPluginStateStore struct {
*MockPluginStore
*MockPluginConfig
}
MockPluginStateStore combines MockPluginStore and MockPluginConfig behind the ports.PluginStateStore composite interface. Both halves share a single states map so that mutations made through one interface are visible through the other.
func NewMockPluginStateStore ¶
func NewMockPluginStateStore() *MockPluginStateStore
NewMockPluginStateStore creates a new MockPluginStateStore with shared state.
type MockPluginStore ¶
type MockPluginStore struct {
SaveFunc func(ctx context.Context) error
LoadFunc func(ctx context.Context) error
SaveErr error
LoadErr error
// contains filtered or unexported fields
}
MockPluginStore is a thread-safe mock implementation of ports.PluginStore. It supports optional error injection via SaveErr and LoadErr fields, and custom behavior via SaveFunc and LoadFunc overrides.
func NewMockPluginStore ¶
func NewMockPluginStore() *MockPluginStore
NewMockPluginStore creates a new thread-safe mock plugin store.
func (*MockPluginStore) GetState ¶
func (m *MockPluginStore) GetState(name string) *pluginmodel.PluginState
GetState returns the full state for a plugin, or nil if not found. Thread-safe for concurrent access.
func (*MockPluginStore) ListDisabled ¶
func (m *MockPluginStore) ListDisabled() []string
ListDisabled returns names of all explicitly disabled plugins. Thread-safe for concurrent access.
type MockStateStore ¶
type MockStateStore struct {
// contains filtered or unexported fields
}
MockStateStore is a thread-safe mock implementation of ports.StateStore. It uses sync.RWMutex to protect concurrent access to the states map.
Usage:
store := testutil.NewMockStateStore() err := store.Save(ctx, state) loaded, err := store.Load(ctx, "workflow-id")
func NewMockStateStore ¶
func NewMockStateStore() *MockStateStore
NewMockStateStore creates a new thread-safe mock state store.
func (*MockStateStore) Clear ¶
func (m *MockStateStore) Clear()
Clear removes all states from the store (test helper).
func (*MockStateStore) Delete ¶
func (m *MockStateStore) Delete(ctx context.Context, workflowID string) error
Delete removes an execution context by workflow ID.
func (*MockStateStore) List ¶
func (m *MockStateStore) List(ctx context.Context) ([]string, error)
List returns all workflow IDs that have stored states.
func (*MockStateStore) Load ¶
func (m *MockStateStore) Load(ctx context.Context, workflowID string) (*workflow.ExecutionContext, error)
Load retrieves an execution context by workflow ID.
func (*MockStateStore) Save ¶
func (m *MockStateStore) Save(ctx context.Context, state *workflow.ExecutionContext) error
Save persists an execution context.
func (*MockStateStore) SetDeleteError ¶
func (m *MockStateStore) SetDeleteError(err error)
SetDeleteError configures the mock to return an error on Delete calls (test helper).
func (*MockStateStore) SetListError ¶
func (m *MockStateStore) SetListError(err error)
SetListError configures the mock to return an error on List calls (test helper).
func (*MockStateStore) SetLoadError ¶
func (m *MockStateStore) SetLoadError(err error)
SetLoadError configures the mock to return an error on Load calls (test helper).
func (*MockStateStore) SetSaveError ¶
func (m *MockStateStore) SetSaveError(err error)
SetSaveError configures the mock to return an error on Save calls (test helper).
type MockTemplateRepository ¶
type MockTemplateRepository struct {
// contains filtered or unexported fields
}
MockTemplateRepository is a thread-safe mock implementation of ports.TemplateRepository. It uses sync.RWMutex to protect concurrent access to the templates map.
Usage:
repo := testutil.NewMockTemplateRepository()
repo.AddTemplate("test", &workflow.Template{Name: "test"})
tpl, err := repo.GetTemplate(ctx, "test")
func NewMockTemplateRepository ¶
func NewMockTemplateRepository() *MockTemplateRepository
NewMockTemplateRepository creates a new thread-safe mock template repository.
func (*MockTemplateRepository) AddTemplate ¶
func (m *MockTemplateRepository) AddTemplate(name string, tpl *workflow.Template)
AddTemplate adds or updates a template in the repository (test helper). Thread-safe for concurrent access.
func (*MockTemplateRepository) Clear ¶
func (m *MockTemplateRepository) Clear()
Clear removes all templates and resets error configuration (test helper). Thread-safe for concurrent access.
func (*MockTemplateRepository) Exists ¶
func (m *MockTemplateRepository) Exists(ctx context.Context, name string) bool
Exists checks if a template with the given name exists. Thread-safe for concurrent access.
func (*MockTemplateRepository) GetTemplate ¶
func (m *MockTemplateRepository) GetTemplate(ctx context.Context, name string) (*workflow.Template, error)
GetTemplate retrieves a template by name. Returns TemplateNotFoundError if template does not exist. Thread-safe for concurrent access.
func (*MockTemplateRepository) ListTemplates ¶
func (m *MockTemplateRepository) ListTemplates(ctx context.Context) ([]string, error)
ListTemplates returns all template names in the repository. Thread-safe for concurrent access.
func (*MockTemplateRepository) SetGetError ¶
func (m *MockTemplateRepository) SetGetError(err error)
SetGetError configures an error to be returned by GetTemplate (test helper). Thread-safe for concurrent access.
func (*MockTemplateRepository) SetListError ¶
func (m *MockTemplateRepository) SetListError(err error)
SetListError configures an error to be returned by ListTemplates (test helper). Thread-safe for concurrent access.
type MockWorkflowRepository ¶
type MockWorkflowRepository struct {
// contains filtered or unexported fields
}
MockWorkflowRepository is a thread-safe mock implementation of ports.WorkflowRepository. It uses sync.RWMutex to protect concurrent access to the workflows map.
Usage:
repo := testutil.NewMockWorkflowRepository()
repo.AddWorkflow("test", &workflow.Workflow{Name: "test"})
wf, err := repo.Load(ctx, "test")
func NewMockWorkflowRepository ¶
func NewMockWorkflowRepository() *MockWorkflowRepository
NewMockWorkflowRepository creates a new thread-safe mock workflow repository.
func (*MockWorkflowRepository) AddWorkflow ¶
func (m *MockWorkflowRepository) AddWorkflow(name string, wf *workflow.Workflow)
AddWorkflow adds or updates a workflow in the repository. Thread-safe for concurrent access.
func (*MockWorkflowRepository) Clear ¶
func (m *MockWorkflowRepository) Clear()
Clear removes all workflows and resets error configuration. Thread-safe for concurrent access.
func (*MockWorkflowRepository) Exists ¶
Exists checks if a workflow with the given name exists. Thread-safe for concurrent access.
func (*MockWorkflowRepository) List ¶
func (m *MockWorkflowRepository) List(ctx context.Context) ([]string, error)
List returns all workflow names in the repository. Thread-safe for concurrent access.
func (*MockWorkflowRepository) Load ¶
Load retrieves a workflow by name. Returns StructuredError with USER.INPUT.MISSING_FILE if workflow does not exist. Thread-safe for concurrent access.
func (*MockWorkflowRepository) SetExistsError ¶
func (m *MockWorkflowRepository) SetExistsError(err error)
SetExistsError configures an error to be returned by Exists. Thread-safe for concurrent access.
func (*MockWorkflowRepository) SetListError ¶
func (m *MockWorkflowRepository) SetListError(err error)
SetListError configures an error to be returned by List. Thread-safe for concurrent access.
func (*MockWorkflowRepository) SetLoadError ¶
func (m *MockWorkflowRepository) SetLoadError(err error)
SetLoadError configures an error to be returned by Load. Thread-safe for concurrent access.