mocks

package
v0.11.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: EUPL-1.2 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogMessage

type LogMessage struct {
	Level  string
	Msg    string
	Fields []any
}

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, stdout, stderr io.Writer) (*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, stdout, stderr io.Writer) (*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, stdout, stderr io.Writer) (*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, stdout, stderr io.Writer) (*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, stdout, stderr io.Writer) (*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

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 MockAgentRoleRepository added in v0.11.2

type MockAgentRoleRepository struct {
	LoadFunc         func(ctx context.Context, name string) (*workflow.AgentRole, error)
	LoadFromPathFunc func(ctx context.Context, absolutePath string) (*workflow.AgentRole, error)
}

MockAgentRoleRepository is a mock implementation of ports.AgentRoleRepository with injectable function fields for fine-grained test control.

func (*MockAgentRoleRepository) Load added in v0.11.2

Load delegates to LoadFunc.

func (*MockAgentRoleRepository) LoadFromPath added in v0.11.2

func (m *MockAgentRoleRepository) LoadFromPath(ctx context.Context, absolutePath string) (*workflow.AgentRole, error)

LoadFromPath delegates to LoadFromPathFunc.

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

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

type MockCLICall struct {
	Name string
	Args []string
}

MockCLICall records a single CLI execution call.

type MockCLIExecutor

type MockCLIExecutor struct {
	StartFunc func(ctx context.Context, name string, args ...string) (ports.CLIProcess, error)
	// 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", nil, nil, "--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) GetStartCalls added in v0.11.2

func (m *MockCLIExecutor) GetStartCalls() []MockCLIStartCall

GetStartCalls returns all recorded Start calls (test helper).

func (*MockCLIExecutor) Run

func (m *MockCLIExecutor) Run(ctx context.Context, name string, stdoutW, stderrW io.Writer, 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).

func (*MockCLIExecutor) Start added in v0.11.2

func (m *MockCLIExecutor) Start(ctx context.Context, name string, args ...string) (ports.CLIProcess, error)

Start records the call and delegates to StartFunc if configured, or returns a default MockCLIProcess.

type MockCLIProcess added in v0.11.2

type MockCLIProcess struct {
	// contains filtered or unexported fields
}

MockCLIProcess is a test-controlled implementation of ports.CLIProcess. Tests can signal completion via Close() and configure Wait errors.

func NewMockCLIProcess added in v0.11.2

func NewMockCLIProcess() *MockCLIProcess

NewMockCLIProcess creates a MockCLIProcess whose Done channel is open until Close is called.

func (*MockCLIProcess) Close added in v0.11.2

func (p *MockCLIProcess) Close()

Close simulates process exit, closing the Done channel exactly once.

func (*MockCLIProcess) Done added in v0.11.2

func (p *MockCLIProcess) Done() <-chan struct{}

Done returns a channel that is closed when Close is called.

func (*MockCLIProcess) GetSignals added in v0.11.2

func (p *MockCLIProcess) GetSignals() []os.Signal

GetSignals returns all signals sent to the process (test helper).

func (*MockCLIProcess) SetWaitError added in v0.11.2

func (p *MockCLIProcess) SetWaitError(err error)

SetWaitError configures the error returned by Wait (test helper).

func (*MockCLIProcess) Signal added in v0.11.2

func (p *MockCLIProcess) Signal(sig os.Signal) error

Signal records the signal sent to the process.

func (*MockCLIProcess) Wait added in v0.11.2

func (p *MockCLIProcess) Wait() error

Wait returns the configured wait error and is idempotent.

type MockCLIStartCall added in v0.11.2

type MockCLIStartCall struct {
	Name string
	Args []string
}

MockCLIStartCall records a single Start call.

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

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 MockEventPublisher added in v0.11.2

type MockEventPublisher struct {
	// contains filtered or unexported fields
}

MockEventPublisher is a thread-safe mock implementation of ports.EventPublisher. It collects published events for assertion in tests.

func NewMockEventPublisher added in v0.11.2

func NewMockEventPublisher() *MockEventPublisher

NewMockEventPublisher creates a new thread-safe mock event publisher.

func (*MockEventPublisher) Clear added in v0.11.2

func (m *MockEventPublisher) Clear()

Clear removes all collected events and resets error state (test helper). Thread-safe for concurrent access.

func (*MockEventPublisher) Close added in v0.11.2

func (m *MockEventPublisher) Close() error

Close is a no-op for the mock publisher. Thread-safe for concurrent access.

func (*MockEventPublisher) GetEvents added in v0.11.2

func (m *MockEventPublisher) GetEvents() []*pluginmodel.DomainEvent

GetEvents returns a copy of all published events (test helper). Thread-safe for concurrent access.

func (*MockEventPublisher) Publish added in v0.11.2

Publish appends the event to the internal slice; returns publishErr if set. Thread-safe for concurrent access.

func (*MockEventPublisher) SetPublishError added in v0.11.2

func (m *MockEventPublisher) SetPublishError(err error)

SetPublishError causes subsequent Publish calls to return err (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

func (m *MockHistoryStore) Cleanup(ctx context.Context, olderThan time.Duration) (int, error)

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

GetStats returns empty stats (not implemented in mock).

func (*MockHistoryStore) List

List returns all recorded execution records (filter is ignored in mock).

func (*MockHistoryStore) Record

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 MockOperationCall added in v0.11.2

type MockOperationCall struct {
	Name   string
	Inputs map[string]any
}

MockOperationCall records a single Execute call.

type MockOperationProvider added in v0.11.2

type MockOperationProvider struct {
	// contains filtered or unexported fields
}

MockOperationProvider is a thread-safe mock implementation of ports.OperationProvider.

func NewMockOperationProvider added in v0.11.2

func NewMockOperationProvider() *MockOperationProvider

NewMockOperationProvider creates a new thread-safe mock operation provider.

func (*MockOperationProvider) AddOperation added in v0.11.2

func (m *MockOperationProvider) AddOperation(schema *pluginmodel.OperationSchema)

AddOperation registers an operation schema (test helper). It indexes the schema under both its short name (e.g. "send") and the fully-qualified "pluginName.opName" form (e.g. "notify.send") so that tests work whether the caller passes a prefixed or unprefixed name to GetOperation. Thread-safe for concurrent access.

func (*MockOperationProvider) Clear added in v0.11.2

func (m *MockOperationProvider) Clear()

Clear removes all operations and resets configuration (test helper). Thread-safe for concurrent access.

func (*MockOperationProvider) Execute added in v0.11.2

func (m *MockOperationProvider) Execute(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error)

Execute dispatches the named operation and records the call. Thread-safe for concurrent access.

func (*MockOperationProvider) GetExecuteCalls added in v0.11.2

func (m *MockOperationProvider) GetExecuteCalls() []MockOperationCall

GetExecuteCalls returns all recorded Execute calls (test helper). Thread-safe for concurrent access.

func (*MockOperationProvider) GetOperation added in v0.11.2

func (m *MockOperationProvider) GetOperation(name string) (*pluginmodel.OperationSchema, bool)

GetOperation returns the operation schema for name, or (nil, false) if absent. Thread-safe for concurrent access.

func (*MockOperationProvider) ListOperations added in v0.11.2

func (m *MockOperationProvider) ListOperations() []*pluginmodel.OperationSchema

ListOperations returns all registered operation schemas. Thread-safe for concurrent access.

func (*MockOperationProvider) SetExecuteError added in v0.11.2

func (m *MockOperationProvider) SetExecuteError(err error)

SetExecuteError configures an error to be returned by Execute (test helper). Thread-safe for concurrent access.

func (*MockOperationProvider) SetExecuteFunc added in v0.11.2

func (m *MockOperationProvider) SetExecuteFunc(fn func(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error))

SetExecuteFunc configures a custom function for Execute calls (test helper). Thread-safe for concurrent access.

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

func (m *MockPluginConfig) SetConfig(ctx context.Context, name string, config map[string]any) error

SetConfig stores configuration for a plugin. Returns SetConfigErr if set. Thread-safe for concurrent access.

func (*MockPluginConfig) SetEnabled

func (m *MockPluginConfig) SetEnabled(ctx context.Context, name string, enabled bool) error

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

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

Discover finds plugins in the plugins directory. Thread-safe for concurrent access.

func (*MockPluginManager) Get

Get returns plugin info by name. Thread-safe for concurrent access.

func (*MockPluginManager) Init

func (m *MockPluginManager) Init(ctx context.Context, name string, config map[string]any) error

Init initializes a loaded plugin. Thread-safe for concurrent access.

func (*MockPluginManager) List

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.

func (*MockPluginStore) Load

func (m *MockPluginStore) Load(ctx context.Context) error

Load reads plugin states. Honors LoadFunc override, then LoadErr, then returns nil. Thread-safe for concurrent access.

func (*MockPluginStore) Save

func (m *MockPluginStore) Save(ctx context.Context) error

Save persists plugin states. Honors SaveFunc override, then SaveErr, then returns nil. Thread-safe for concurrent access.

type MockSkillRepository added in v0.11.2

type MockSkillRepository struct {
	// contains filtered or unexported fields
}

MockSkillRepository is a thread-safe mock implementation of ports.SkillRepository.

func NewMockSkillRepository added in v0.11.2

func NewMockSkillRepository() *MockSkillRepository

NewMockSkillRepository creates a new thread-safe mock skill repository.

func (*MockSkillRepository) Load added in v0.11.2

func (m *MockSkillRepository) Load(ctx context.Context, name string) (*workflow.Skill, error)

Load retrieves a skill by name. Thread-safe for concurrent access.

func (*MockSkillRepository) LoadFromPath added in v0.11.2

func (m *MockSkillRepository) LoadFromPath(ctx context.Context, absolutePath string) (*workflow.Skill, error)

LoadFromPath retrieves a skill by its absolute file path. Thread-safe for concurrent access.

func (*MockSkillRepository) SetLoadError added in v0.11.2

func (m *MockSkillRepository) SetLoadError(err error)

SetLoadError configures an error to be returned by Load and LoadFromPath (test helper). Thread-safe for concurrent access.

func (*MockSkillRepository) SetSkill added in v0.11.2

func (m *MockSkillRepository) SetSkill(name string, skill *workflow.Skill)

SetSkill adds or updates a skill in the repository (test helper). Thread-safe for concurrent access.

type MockSpan added in v0.11.2

type MockSpan struct {
	// contains filtered or unexported fields
}

MockSpan is a thread-safe mock implementation of ports.Span.

func (*MockSpan) AddEvent added in v0.11.2

func (m *MockSpan) AddEvent(name string)

func (*MockSpan) End added in v0.11.2

func (m *MockSpan) End()

func (*MockSpan) Record added in v0.11.2

func (m *MockSpan) Record() *MockSpanRecord

Record returns the span's recorded data (test helper).

func (*MockSpan) RecordError added in v0.11.2

func (m *MockSpan) RecordError(err error)

func (*MockSpan) SetAttribute added in v0.11.2

func (m *MockSpan) SetAttribute(key string, value any)

type MockSpanRecord added in v0.11.2

type MockSpanRecord struct {
	Name       string
	Ended      bool
	Attributes map[string]any
	Errors     []error
	Events     []string
}

MockSpanRecord holds recorded calls made against a single span.

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

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 MockTracer added in v0.11.2

type MockTracer struct {
	// contains filtered or unexported fields
}

MockTracer is a thread-safe mock implementation of ports.Tracer.

func NewMockTracer added in v0.11.2

func NewMockTracer() *MockTracer

NewMockTracer creates a new thread-safe mock tracer.

func (*MockTracer) Clear added in v0.11.2

func (m *MockTracer) Clear()

Clear removes all recorded spans (test helper).

func (*MockTracer) GetSpans added in v0.11.2

func (m *MockTracer) GetSpans() []*MockSpan

GetSpans returns all spans created by this tracer (test helper).

func (*MockTracer) Start added in v0.11.2

func (m *MockTracer) Start(ctx context.Context, spanName string) (context.Context, ports.Span)

type MockUserInputReader added in v0.11.2

type MockUserInputReader struct {
	// contains filtered or unexported fields
}

MockUserInputReader is a thread-safe mock implementation of ports.UserInputReader. It uses sync.Mutex to protect concurrent access to the response queue.

Usage:

reader := testutil.NewMockUserInputReader("hello", "world", "")
input, err := reader.ReadInput(ctx)

func NewMockUserInputReader added in v0.11.2

func NewMockUserInputReader(responses ...string) *MockUserInputReader

NewMockUserInputReader creates a new thread-safe mock input reader. Responses are returned in sequence; empty string signals conversation exit. When all responses are consumed, returns empty string.

func (*MockUserInputReader) AddResponse added in v0.11.2

func (m *MockUserInputReader) AddResponse(response string)

AddResponse appends a response to the sequence (test helper). Thread-safe for concurrent access.

func (*MockUserInputReader) Clear added in v0.11.2

func (m *MockUserInputReader) Clear()

Clear removes all responses and resets error configuration (test helper). Thread-safe for concurrent access.

func (*MockUserInputReader) GetCallCount added in v0.11.2

func (m *MockUserInputReader) GetCallCount() int

GetCallCount returns the number of ReadInput calls (test helper). Thread-safe for concurrent access.

func (*MockUserInputReader) ReadInput added in v0.11.2

func (m *MockUserInputReader) ReadInput(ctx context.Context) (string, error)

ReadInput returns the next configured response in sequence. Returns configured error if set. Respects context cancellation. Thread-safe for concurrent access.

func (*MockUserInputReader) SetReadError added in v0.11.2

func (m *MockUserInputReader) SetReadError(err error)

SetReadError configures an error to be returned by ReadInput (test helper). Thread-safe for concurrent access.

func (*MockUserInputReader) SetResponses added in v0.11.2

func (m *MockUserInputReader) SetResponses(responses ...string)

SetResponses replaces the response sequence (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

func (m *MockWorkflowRepository) Exists(ctx context.Context, name string) (bool, error)

Exists checks if a workflow with the given name exists. Thread-safe for concurrent access.

func (*MockWorkflowRepository) List

List returns all workflow names in the repository. Thread-safe for concurrent access.

func (*MockWorkflowRepository) ListWithSource added in v0.11.2

func (m *MockWorkflowRepository) ListWithSource(ctx context.Context) ([]ports.WorkflowInfo, error)

ListWithSource returns all workflow names together with their discovery source. All entries report SourceLocal since the mock does not distinguish origins. 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL