Documentation
¶
Overview ¶
Package testsupport provides shared test fakes for interfaces defined in the api package. These are intended for use across multiple test packages to avoid duplicating interface implementations.
Index ¶
- func ACPBridgeContractTest(t *testing.T, b api.ACPBridge)
- func ChatStoreContractTest(t *testing.T, newStore func(t *testing.T) api.ChatStore)
- func MCPConfigContractTest(t *testing.T, newConfig func(t *testing.T) api.MCPConfig)
- type CaptureBroadcaster
- type InMemoryChatStore
- func (s *InMemoryChatStore) AppendMessage(_ context.Context, chatID api.ChatID, msg *api.Message) error
- func (s *InMemoryChatStore) Archive(_ context.Context, id api.ChatID) error
- func (s *InMemoryChatStore) BuildHistory(_ context.Context, id api.ChatID) string
- func (s *InMemoryChatStore) ChildrenOf(_ context.Context, parentID api.ChatID) []api.ChatID
- func (s *InMemoryChatStore) Delete(_ context.Context, id api.ChatID) error
- func (s *InMemoryChatStore) DeleteArchived(_ context.Context, _ api.ChatID) error
- func (s *InMemoryChatStore) DeleteFamily(ctx context.Context, parentID api.ChatID, prepare func(api.ChatID)) ([]api.ChatID, error)
- func (s *InMemoryChatStore) Get(_ context.Context, id api.ChatID) (*api.Chat, bool)
- func (s *InMemoryChatStore) List(_ context.Context) []api.ChatHeader
- func (s *InMemoryChatStore) ListArchived(_ context.Context) []api.ChatHeader
- func (s *InMemoryChatStore) LoadArchived(_ context.Context, _ api.ChatID) (*api.Chat, error)
- func (s *InMemoryChatStore) Mutate(_ context.Context, id api.ChatID, mutate func(*api.Chat, bool) bool) error
- func (s *InMemoryChatStore) PromoteRewind(ctx context.Context, childID api.ChatID) (api.ChatID, error)
- func (s *InMemoryChatStore) RegisterRoutes(_ *http.ServeMux)
- func (s *InMemoryChatStore) RestoreArchived(_ context.Context, _ api.ChatID) error
- func (s *InMemoryChatStore) SetBroadcaster(b api.Broadcaster)
- func (s *InMemoryChatStore) UpdateArchivedSummary(_ context.Context, _ api.ChatID, _ string) error
- func (s *InMemoryChatStore) UpdateMessage(_ context.Context, chatID api.ChatID, msgID string, mutate func(*api.Message)) error
- type NopACPBridge
- func (*NopACPBridge) Call(context.Context, string, any) (*api.RPCResponse, error)
- func (*NopACPBridge) CurrentMode() string
- func (*NopACPBridge) ModelID() api.ModelID
- func (*NopACPBridge) Models() []api.SessionModel
- func (*NopACPBridge) Modes() []api.SessionMode
- func (*NopACPBridge) NotifCh() <-chan *api.RPCResponse
- func (*NopACPBridge) Notify(context.Context, string, any) error
- func (*NopACPBridge) Respond(context.Context, int64, any, error) error
- func (*NopACPBridge) SessionID() api.SessionID
- func (*NopACPBridge) SetModel(context.Context, string) error
- func (*NopACPBridge) Start(context.Context, *api.StartOpts) error
- func (*NopACPBridge) Stop()
- type NopBroadcaster
- type NopChatStore
- func (NopChatStore) AppendMessage(context.Context, api.ChatID, *api.Message) error
- func (NopChatStore) Archive(context.Context, api.ChatID) error
- func (NopChatStore) BuildHistory(context.Context, api.ChatID) string
- func (NopChatStore) ChildrenOf(context.Context, api.ChatID) []api.ChatID
- func (NopChatStore) Delete(context.Context, api.ChatID) error
- func (NopChatStore) DeleteArchived(context.Context, api.ChatID) error
- func (NopChatStore) DeleteFamily(context.Context, api.ChatID, func(api.ChatID)) ([]api.ChatID, error)
- func (NopChatStore) Get(context.Context, api.ChatID) (*api.Chat, bool)
- func (NopChatStore) List(context.Context) []api.ChatHeader
- func (NopChatStore) ListArchived(context.Context) []api.ChatHeader
- func (NopChatStore) LoadArchived(context.Context, api.ChatID) (*api.Chat, error)
- func (NopChatStore) Mutate(context.Context, api.ChatID, func(*api.Chat, bool) bool) error
- func (NopChatStore) PromoteRewind(context.Context, api.ChatID) (api.ChatID, error)
- func (NopChatStore) RegisterRoutes(*http.ServeMux)
- func (NopChatStore) RestoreArchived(context.Context, api.ChatID) error
- func (NopChatStore) SetBroadcaster(api.Broadcaster)
- func (NopChatStore) UpdateArchivedSummary(context.Context, api.ChatID, string) error
- func (NopChatStore) UpdateMessage(context.Context, api.ChatID, string, func(*api.Message)) error
- type NopMCPRecorder
- func (*NopMCPRecorder) RecordConnected(context.Context, string, []api.MCPPromptInfo, []api.MCPResourceInfo)
- func (*NopMCPRecorder) RecordInitFailure(context.Context, string, string)
- func (*NopMCPRecorder) RecordOAuth(context.Context, string, string)
- func (*NopMCPRecorder) SetKnownTools(context.Context, string, []string)
- func (*NopMCPRecorder) SignalReady()
- type RecordingChatStore
- func (s *RecordingChatStore) AppendMessage(_ context.Context, chatID api.ChatID, msg *api.Message) error
- func (s *RecordingChatStore) Archive(_ context.Context, id api.ChatID) error
- func (s *RecordingChatStore) BuildHistory(_ context.Context, id api.ChatID) string
- func (s *RecordingChatStore) ChildrenOf(_ context.Context, parentID api.ChatID) []api.ChatID
- func (s *RecordingChatStore) Delete(_ context.Context, id api.ChatID) error
- func (s *RecordingChatStore) DeleteArchived(_ context.Context, _ api.ChatID) error
- func (s *RecordingChatStore) DeleteFamily(ctx context.Context, parentID api.ChatID, prepare func(api.ChatID)) ([]api.ChatID, error)
- func (s *RecordingChatStore) Get(_ context.Context, id api.ChatID) (*api.Chat, bool)
- func (s *RecordingChatStore) List(_ context.Context) []api.ChatHeader
- func (s *RecordingChatStore) ListArchived(_ context.Context) []api.ChatHeader
- func (s *RecordingChatStore) LoadArchived(_ context.Context, _ api.ChatID) (*api.Chat, error)
- func (s *RecordingChatStore) Mutate(_ context.Context, id api.ChatID, mutate func(*api.Chat, bool) bool) error
- func (s *RecordingChatStore) PromoteRewind(ctx context.Context, childID api.ChatID) (api.ChatID, error)
- func (s *RecordingChatStore) RegisterRoutes(_ *http.ServeMux)
- func (s *RecordingChatStore) RestoreArchived(_ context.Context, _ api.ChatID) error
- func (s *RecordingChatStore) SetBroadcaster(b api.Broadcaster)
- func (s *RecordingChatStore) UpdateArchivedSummary(_ context.Context, _ api.ChatID, _ string) error
- func (s *RecordingChatStore) UpdateMessage(_ context.Context, chatID api.ChatID, msgID string, mutate func(*api.Message)) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ACPBridgeContractTest ¶
ACPBridgeContractTest verifies that an api.ACPBridge implementation satisfies the basic contract: Start/Stop don't panic, NotifCh is non-nil or nil consistently, and Stop is idempotent.
func ChatStoreContractTest ¶
ChatStoreContractTest exercises the behavioral expectations of any api.ChatStore implementation. Run against both fakes and real implementations to catch drift. Each behavior lives in its own helper so the suite stays flat; this is the dispatcher.
Types ¶
type CaptureBroadcaster ¶
type CaptureBroadcaster struct {
// contains filtered or unexported fields
}
CaptureBroadcaster is a thread-safe event capture implementing api.Broadcaster.
func (*CaptureBroadcaster) Broadcast ¶
func (c *CaptureBroadcaster) Broadcast(_ context.Context, e api.ServerEvent)
Broadcast captures the event.
func (*CaptureBroadcaster) Reset ¶
func (c *CaptureBroadcaster) Reset()
Reset clears all captured events.
func (*CaptureBroadcaster) Snapshot ¶
func (c *CaptureBroadcaster) Snapshot() []api.ServerEvent
Snapshot returns a copy of all captured events.
type InMemoryChatStore ¶
type InMemoryChatStore struct {
// contains filtered or unexported fields
}
InMemoryChatStore is a functional in-memory api.ChatStore with broadcast support. Suitable for integration-style tests that need real Mutate/Get semantics without filesystem I/O.
func NewInMemoryChatStore ¶
func NewInMemoryChatStore() *InMemoryChatStore
NewInMemoryChatStore returns a ready-to-use InMemoryChatStore.
func (*InMemoryChatStore) AppendMessage ¶
func (s *InMemoryChatStore) AppendMessage(_ context.Context, chatID api.ChatID, msg *api.Message) error
AppendMessage appends a message to the stored chat and broadcasts message_appended.
func (*InMemoryChatStore) Archive ¶
Archive removes the chat; delegates to Delete for test simplicity.
func (*InMemoryChatStore) BuildHistory ¶
BuildHistory returns the plain-text transcript for the chat with the given id.
func (*InMemoryChatStore) ChildrenOf ¶
ChildrenOf returns the IDs of chats whose ParentChatID equals parentID.
func (*InMemoryChatStore) Delete ¶
Delete removes the chat with the given id and broadcasts a chat_deleted event.
func (*InMemoryChatStore) DeleteArchived ¶
DeleteArchived is a no-op; implements api.ChatStore.
func (*InMemoryChatStore) DeleteFamily ¶ added in v0.2.8
func (s *InMemoryChatStore) DeleteFamily(ctx context.Context, parentID api.ChatID, prepare func(api.ChatID)) ([]api.ChatID, error)
DeleteFamily removes children first, then the parent, mirroring the real store's ordering contract; implements api.ChatStore.
func (*InMemoryChatStore) Get ¶
Get returns a copy of the stored chat for id, or (nil, false) if not found.
func (*InMemoryChatStore) List ¶
func (s *InMemoryChatStore) List(_ context.Context) []api.ChatHeader
List returns headers for all stored chats.
func (*InMemoryChatStore) ListArchived ¶
func (s *InMemoryChatStore) ListArchived(_ context.Context) []api.ChatHeader
ListArchived returns nil; implements api.ChatStore.
func (*InMemoryChatStore) LoadArchived ¶
LoadArchived returns (nil, nil); implements api.ChatStore.
func (*InMemoryChatStore) Mutate ¶
func (s *InMemoryChatStore) Mutate(_ context.Context, id api.ChatID, mutate func(*api.Chat, bool) bool) error
Mutate applies the mutate function to the chat with the given id, creating it if needed.
func (*InMemoryChatStore) PromoteRewind ¶ added in v0.2.8
func (s *InMemoryChatStore) PromoteRewind(ctx context.Context, childID api.ChatID) (api.ChatID, error)
PromoteRewind clears the rewind linkage under one Mutate, mirroring the real store's contract; implements api.ChatStore.
func (*InMemoryChatStore) RegisterRoutes ¶
func (s *InMemoryChatStore) RegisterRoutes(_ *http.ServeMux)
RegisterRoutes is a no-op; implements api.ChatStore.
func (*InMemoryChatStore) RestoreArchived ¶
RestoreArchived is a no-op; implements api.ChatStore.
func (*InMemoryChatStore) SetBroadcaster ¶
func (s *InMemoryChatStore) SetBroadcaster(b api.Broadcaster)
SetBroadcaster sets the broadcaster used to fan out chat lifecycle events.
func (*InMemoryChatStore) UpdateArchivedSummary ¶
UpdateArchivedSummary is a no-op; implements api.ChatStore.
type NopACPBridge ¶
type NopACPBridge struct{}
NopACPBridge is a minimal no-op implementation of api.ACPBridge for benchmarks and tests that need a bridge but don't care about its behavior. All methods return zero values.
func (*NopACPBridge) Call ¶
func (*NopACPBridge) Call(context.Context, string, any) (*api.RPCResponse, error)
Call is a no-op; implements api.ACPBridge.
func (*NopACPBridge) CurrentMode ¶
func (*NopACPBridge) CurrentMode() string
CurrentMode returns an empty mode string; implements api.ACPBridge.
func (*NopACPBridge) ModelID ¶
func (*NopACPBridge) ModelID() api.ModelID
ModelID returns an empty model ID; implements api.ACPBridge.
func (*NopACPBridge) Models ¶
func (*NopACPBridge) Models() []api.SessionModel
Models returns nil; implements api.ACPBridge.
func (*NopACPBridge) Modes ¶
func (*NopACPBridge) Modes() []api.SessionMode
Modes returns nil; implements api.ACPBridge.
func (*NopACPBridge) NotifCh ¶
func (*NopACPBridge) NotifCh() <-chan *api.RPCResponse
NotifCh returns nil; implements api.ACPBridge.
func (*NopACPBridge) SessionID ¶
func (*NopACPBridge) SessionID() api.SessionID
SessionID returns an empty session ID; implements api.ACPBridge.
func (*NopACPBridge) SetModel ¶
func (*NopACPBridge) SetModel(context.Context, string) error
SetModel is a no-op; implements api.ACPBridge.
type NopBroadcaster ¶
type NopBroadcaster struct{}
NopBroadcaster is a zero-alloc no-op satisfying api.Broadcaster.
func (NopBroadcaster) Broadcast ¶
func (NopBroadcaster) Broadcast(_ context.Context, _ api.ServerEvent)
Broadcast is a no-op.
type NopChatStore ¶
type NopChatStore struct{}
NopChatStore is a no-op api.ChatStore implementation for benchmarks. Every method returns zero/nil.
func (NopChatStore) AppendMessage ¶
AppendMessage is a no-op; implements api.ChatStore.
func (NopChatStore) BuildHistory ¶
BuildHistory returns an empty string; implements api.ChatStore.
func (NopChatStore) ChildrenOf ¶
ChildrenOf returns nil; implements api.ChatStore.
func (NopChatStore) DeleteArchived ¶
DeleteArchived is a no-op; implements api.ChatStore.
func (NopChatStore) DeleteFamily ¶ added in v0.2.8
func (NopChatStore) DeleteFamily(context.Context, api.ChatID, func(api.ChatID)) ([]api.ChatID, error)
DeleteFamily is a no-op; implements api.ChatStore.
func (NopChatStore) List ¶
func (NopChatStore) List(context.Context) []api.ChatHeader
List returns nil; implements api.ChatStore.
func (NopChatStore) ListArchived ¶
func (NopChatStore) ListArchived(context.Context) []api.ChatHeader
ListArchived returns nil; implements api.ChatStore.
func (NopChatStore) LoadArchived ¶
LoadArchived returns (nil, nil); implements api.ChatStore.
func (NopChatStore) PromoteRewind ¶ added in v0.2.8
PromoteRewind returns ErrChatNotFound; implements api.ChatStore.
func (NopChatStore) RegisterRoutes ¶
func (NopChatStore) RegisterRoutes(*http.ServeMux)
RegisterRoutes is a no-op; implements api.ChatStore.
func (NopChatStore) RestoreArchived ¶
RestoreArchived is a no-op; implements api.ChatStore.
func (NopChatStore) SetBroadcaster ¶
func (NopChatStore) SetBroadcaster(api.Broadcaster)
SetBroadcaster is a no-op; implements api.ChatStore.
func (NopChatStore) UpdateArchivedSummary ¶
UpdateArchivedSummary is a no-op; implements api.ChatStore.
type NopMCPRecorder ¶
type NopMCPRecorder struct{}
NopMCPRecorder is a no-op implementation of translate.MCPRecorder for tests and benchmarks. The compile-time assertion lives in mcprecorder_test.go to avoid a circular import (translate imports testsupport in its test files).
func (*NopMCPRecorder) RecordConnected ¶
func (*NopMCPRecorder) RecordConnected(context.Context, string, []api.MCPPromptInfo, []api.MCPResourceInfo)
RecordConnected is a no-op; implements translate.MCPRecorder.
func (*NopMCPRecorder) RecordInitFailure ¶
func (*NopMCPRecorder) RecordInitFailure(context.Context, string, string)
RecordInitFailure is a no-op; implements translate.MCPRecorder.
func (*NopMCPRecorder) RecordOAuth ¶
func (*NopMCPRecorder) RecordOAuth(context.Context, string, string)
RecordOAuth is a no-op; implements translate.MCPRecorder.
func (*NopMCPRecorder) SetKnownTools ¶
func (*NopMCPRecorder) SetKnownTools(context.Context, string, []string)
SetKnownTools is a no-op; implements translate.MCPRecorder.
func (*NopMCPRecorder) SignalReady ¶
func (*NopMCPRecorder) SignalReady()
SignalReady is a no-op; implements translate.MCPRecorder.
type RecordingChatStore ¶
type RecordingChatStore struct {
Bus api.Broadcaster
Chats map[api.ChatID]*api.Chat
// contains filtered or unexported fields
}
RecordingChatStore is an in-memory api.ChatStore that stores chats in a map and fires broadcasts via an attached Broadcaster. Suitable for integration-style tests that need a ChatStore that actually stores things.
func NewRecordingChatStore ¶
func NewRecordingChatStore() *RecordingChatStore
NewRecordingChatStore returns a ready-to-use RecordingChatStore.
func (*RecordingChatStore) AppendMessage ¶
func (s *RecordingChatStore) AppendMessage(_ context.Context, chatID api.ChatID, msg *api.Message) error
AppendMessage appends a message to the stored chat and broadcasts message_appended.
func (*RecordingChatStore) Archive ¶
Archive removes the chat; delegates to Delete for test simplicity.
func (*RecordingChatStore) BuildHistory ¶
BuildHistory returns the plain-text transcript for the chat with the given id.
func (*RecordingChatStore) ChildrenOf ¶
ChildrenOf returns the IDs of chats whose ParentChatID equals parentID.
func (*RecordingChatStore) Delete ¶
Delete removes the chat with the given id and broadcasts a chat_deleted event.
func (*RecordingChatStore) DeleteArchived ¶
DeleteArchived is a no-op; implements api.ChatStore.
func (*RecordingChatStore) DeleteFamily ¶ added in v0.2.8
func (s *RecordingChatStore) DeleteFamily(ctx context.Context, parentID api.ChatID, prepare func(api.ChatID)) ([]api.ChatID, error)
DeleteFamily removes children first, then the parent, mirroring the real store's ordering contract; implements api.ChatStore.
func (*RecordingChatStore) Get ¶
Get returns a copy of the stored chat for id, or (nil, false) if not found.
func (*RecordingChatStore) List ¶
func (s *RecordingChatStore) List(_ context.Context) []api.ChatHeader
List returns headers for all stored chats.
func (*RecordingChatStore) ListArchived ¶
func (s *RecordingChatStore) ListArchived(_ context.Context) []api.ChatHeader
ListArchived returns nil; implements api.ChatStore.
func (*RecordingChatStore) LoadArchived ¶
LoadArchived returns (nil, nil); implements api.ChatStore.
func (*RecordingChatStore) Mutate ¶
func (s *RecordingChatStore) Mutate(_ context.Context, id api.ChatID, mutate func(*api.Chat, bool) bool) error
Mutate applies the mutate function to the chat with the given id, creating it if needed.
func (*RecordingChatStore) PromoteRewind ¶ added in v0.2.8
func (s *RecordingChatStore) PromoteRewind(ctx context.Context, childID api.ChatID) (api.ChatID, error)
PromoteRewind clears the rewind linkage under one Mutate, mirroring the real store's contract; implements api.ChatStore.
func (*RecordingChatStore) RegisterRoutes ¶
func (s *RecordingChatStore) RegisterRoutes(_ *http.ServeMux)
RegisterRoutes is a no-op; implements api.ChatStore.
func (*RecordingChatStore) RestoreArchived ¶
RestoreArchived is a no-op; implements api.ChatStore.
func (*RecordingChatStore) SetBroadcaster ¶
func (s *RecordingChatStore) SetBroadcaster(b api.Broadcaster)
SetBroadcaster sets the broadcaster used to fan out chat lifecycle events.
func (*RecordingChatStore) UpdateArchivedSummary ¶
UpdateArchivedSummary is a no-op; implements api.ChatStore.