Documentation
¶
Overview ¶
Package testutil provides utilities for easier test setup
Index ¶
- type TestEventQueue
- func (m *TestEventQueue) Close() error
- func (m *TestEventQueue) Read(ctx context.Context) (*eventqueue.Message, error)
- func (m *TestEventQueue) SetCloseError(err error) *TestEventQueue
- func (m *TestEventQueue) SetReadOverride(event a2a.Event, err error) *TestEventQueue
- func (m *TestEventQueue) SetReadVersionedOverride(event a2a.Event, version taskstore.TaskVersion, err error) *TestEventQueue
- func (m *TestEventQueue) SetWriteError(err error) *TestEventQueue
- func (m *TestEventQueue) Write(ctx context.Context, msg *eventqueue.Message) error
- type TestPushConfigStore
- func (m *TestPushConfigStore) Delete(ctx context.Context, taskID a2a.TaskID, configID string) error
- func (m *TestPushConfigStore) DeleteAll(ctx context.Context, taskID a2a.TaskID) error
- func (m *TestPushConfigStore) Get(ctx context.Context, taskID a2a.TaskID, configID string) (*a2a.PushConfig, error)
- func (m *TestPushConfigStore) List(ctx context.Context, taskID a2a.TaskID) ([]*a2a.PushConfig, error)
- func (m *TestPushConfigStore) Save(ctx context.Context, taskID a2a.TaskID, config *a2a.PushConfig) (*a2a.PushConfig, error)
- func (m *TestPushConfigStore) SetDeleteAllError(err error) *TestPushConfigStore
- func (m *TestPushConfigStore) SetDeleteError(err error) *TestPushConfigStore
- func (m *TestPushConfigStore) SetGetOverride(config *a2a.PushConfig, err error) *TestPushConfigStore
- func (m *TestPushConfigStore) SetListOverride(configs []*a2a.PushConfig, err error) *TestPushConfigStore
- func (m *TestPushConfigStore) SetSaveOverride(config *a2a.PushConfig, err error) *TestPushConfigStore
- func (m *TestPushConfigStore) WithConfigs(t *testing.T, taskID a2a.TaskID, configs ...*a2a.PushConfig) *TestPushConfigStore
- type TestPushSender
- type TestQueueManager
- func (m *TestQueueManager) CreateReader(ctx context.Context, taskID a2a.TaskID) (eventqueue.Reader, error)
- func (m *TestQueueManager) CreateWriter(ctx context.Context, taskID a2a.TaskID) (eventqueue.Writer, error)
- func (m *TestQueueManager) Destroy(ctx context.Context, taskID a2a.TaskID) error
- func (m *TestQueueManager) SetDestroyError(err error) *TestQueueManager
- func (m *TestQueueManager) SetError(err error) *TestQueueManager
- func (m *TestQueueManager) SetQueue(queue *TestEventQueue) *TestQueueManager
- type TestTaskStore
- func (m *TestTaskStore) Create(ctx context.Context, task *a2a.Task) (taskstore.TaskVersion, error)
- func (m *TestTaskStore) Get(ctx context.Context, taskID a2a.TaskID) (*taskstore.StoredTask, error)
- func (m *TestTaskStore) SetGetOverride(task *taskstore.StoredTask, err error) *TestTaskStore
- func (m *TestTaskStore) SetSaveError(err error) *TestTaskStore
- func (m *TestTaskStore) Update(ctx context.Context, req *taskstore.UpdateRequest) (taskstore.TaskVersion, error)
- func (m *TestTaskStore) WithTasks(t *testing.T, tasks ...*a2a.Task) *TestTaskStore
- type TestWorkQueue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestEventQueue ¶
type TestEventQueue struct {
ReadFunc func(ctx context.Context) (*eventqueue.Message, error)
WriteFunc func(ctx context.Context, msg *eventqueue.Message) error
CloseFunc func() error
// contains filtered or unexported fields
}
TestEventQueue is a mock of eventqueue.Queue
func NewTestEventQueue ¶
func NewTestEventQueue() *TestEventQueue
NewTestEventQueue allows to mock execution of read, write and close. Without any overrides it defaults to in memory implementation.
func (*TestEventQueue) Close ¶
func (m *TestEventQueue) Close() error
Close implements eventqueue.Reader and eventqueue.Writer interfaces.
func (*TestEventQueue) Read ¶
func (m *TestEventQueue) Read(ctx context.Context) (*eventqueue.Message, error)
Read implements eventqueue.Reader interface.
func (*TestEventQueue) SetCloseError ¶
func (m *TestEventQueue) SetCloseError(err error) *TestEventQueue
SetCloseError overrides Close execution with given error
func (*TestEventQueue) SetReadOverride ¶
func (m *TestEventQueue) SetReadOverride(event a2a.Event, err error) *TestEventQueue
SetReadOverride overrides Read execution
func (*TestEventQueue) SetReadVersionedOverride ¶ added in v0.3.4
func (m *TestEventQueue) SetReadVersionedOverride(event a2a.Event, version taskstore.TaskVersion, err error) *TestEventQueue
SetReadVersionedOverride overrides Read execution with an option to provide a version.
func (*TestEventQueue) SetWriteError ¶
func (m *TestEventQueue) SetWriteError(err error) *TestEventQueue
SetWriteError overrides Write execution with given error
func (*TestEventQueue) Write ¶
func (m *TestEventQueue) Write(ctx context.Context, msg *eventqueue.Message) error
Write implements eventqueue.Writer interface.
type TestPushConfigStore ¶
type TestPushConfigStore struct {
*push.InMemoryPushConfigStore
SaveFunc func(ctx context.Context, taskID a2a.TaskID, config *a2a.PushConfig) (*a2a.PushConfig, error)
GetFunc func(ctx context.Context, taskID a2a.TaskID, configID string) (*a2a.PushConfig, error)
ListFunc func(ctx context.Context, taskID a2a.TaskID) ([]*a2a.PushConfig, error)
DeleteFunc func(ctx context.Context, taskID a2a.TaskID, configID string) error
DeleteAllFunc func(ctx context.Context, taskID a2a.TaskID) error
}
TestPushConfigStore is a mock of push.PushConfigStore.
func NewTestPushConfigStore ¶
func NewTestPushConfigStore() *TestPushConfigStore
NewTestPushConfigStore allows to mock execution of push config store operations. Without any overrides it defaults to in memory implementation.
func (*TestPushConfigStore) Delete ¶
Delete implements push.ConfigStore interface.
func (*TestPushConfigStore) DeleteAll ¶
DeleteAll implements push.ConfigStore interface.
func (*TestPushConfigStore) Get ¶
func (m *TestPushConfigStore) Get(ctx context.Context, taskID a2a.TaskID, configID string) (*a2a.PushConfig, error)
Get implements push.ConfigStore interface.
func (*TestPushConfigStore) List ¶
func (m *TestPushConfigStore) List(ctx context.Context, taskID a2a.TaskID) ([]*a2a.PushConfig, error)
List implements push.ConfigStore interface.
func (*TestPushConfigStore) Save ¶
func (m *TestPushConfigStore) Save(ctx context.Context, taskID a2a.TaskID, config *a2a.PushConfig) (*a2a.PushConfig, error)
Save implements push.ConfigStore interface.
func (*TestPushConfigStore) SetDeleteAllError ¶
func (m *TestPushConfigStore) SetDeleteAllError(err error) *TestPushConfigStore
SetDeleteAllError overrides Delete execution with given error
func (*TestPushConfigStore) SetDeleteError ¶
func (m *TestPushConfigStore) SetDeleteError(err error) *TestPushConfigStore
SetDeleteError overrides Delete execution with given error
func (*TestPushConfigStore) SetGetOverride ¶
func (m *TestPushConfigStore) SetGetOverride(config *a2a.PushConfig, err error) *TestPushConfigStore
SetGetOverride overrides Get execution
func (*TestPushConfigStore) SetListOverride ¶
func (m *TestPushConfigStore) SetListOverride(configs []*a2a.PushConfig, err error) *TestPushConfigStore
SetListOverride overrides List execution
func (*TestPushConfigStore) SetSaveOverride ¶
func (m *TestPushConfigStore) SetSaveOverride(config *a2a.PushConfig, err error) *TestPushConfigStore
SetSaveOverride overrides Save execution
func (*TestPushConfigStore) WithConfigs ¶
func (m *TestPushConfigStore) WithConfigs(t *testing.T, taskID a2a.TaskID, configs ...*a2a.PushConfig) *TestPushConfigStore
WithConfigs seeds PushConfigStore with given configs.
type TestPushSender ¶
type TestPushSender struct {
*push.HTTPPushSender
PushedTasks []*a2a.Task
PushedConfigs []*a2a.PushConfig
SendPushFunc func(ctx context.Context, config *a2a.PushConfig, task *a2a.Task) error
}
TestPushSender is a mock of push.Sender.
func NewTestPushSender ¶
func NewTestPushSender(t *testing.T) *TestPushSender
NewTestPushSender creates a new TestPushSender.
func (*TestPushSender) SendPush ¶
func (m *TestPushSender) SendPush(ctx context.Context, config *a2a.PushConfig, task *a2a.Task) error
SendPush calls the underlying SendPushFunc if it's set. If not, it calls the embedded HTTPPushSender's SendPush method.
func (*TestPushSender) SetSendPushError ¶
func (m *TestPushSender) SetSendPushError(err error) *TestPushSender
SetSendPushError overrides SendPush execution with given error
type TestQueueManager ¶
type TestQueueManager struct {
eventqueue.Manager
CreateWriterFunc func(ctx context.Context, taskID a2a.TaskID) (eventqueue.Writer, error)
CreateReaderFunc func(ctx context.Context, taskID a2a.TaskID) (eventqueue.Reader, error)
DestroyFunc func(ctx context.Context, taskID a2a.TaskID) error
}
TestQueueManager is a mock of eventqueue.Manager
func NewTestQueueManager ¶
func NewTestQueueManager() *TestQueueManager
NewTestQueueManager allows to mock execution of manager operations. Without any overrides it defaults to in memory implementation.
func (*TestQueueManager) CreateReader ¶
func (m *TestQueueManager) CreateReader(ctx context.Context, taskID a2a.TaskID) (eventqueue.Reader, error)
CreateReader implements eventqueue.Manager interface.
func (*TestQueueManager) CreateWriter ¶
func (m *TestQueueManager) CreateWriter(ctx context.Context, taskID a2a.TaskID) (eventqueue.Writer, error)
CreateWriter implements eventqueue.Manager interface.
func (*TestQueueManager) Destroy ¶
Destroy implements eventqueue.Manager interface.
func (*TestQueueManager) SetDestroyError ¶
func (m *TestQueueManager) SetDestroyError(err error) *TestQueueManager
SetDestroyError overrides Destroy execution with given error
func (*TestQueueManager) SetError ¶
func (m *TestQueueManager) SetError(err error) *TestQueueManager
SetError sets the error to be returned by CreateWriter and CreateReader
func (*TestQueueManager) SetQueue ¶
func (m *TestQueueManager) SetQueue(queue *TestEventQueue) *TestQueueManager
SetQueue sets the queue to be returned by CreateWriter and CreateReader
type TestTaskStore ¶
type TestTaskStore struct {
*taskstore.InMemory
CreateFunc func(ctx context.Context, task *a2a.Task) (taskstore.TaskVersion, error)
UpdateFunc func(ctx context.Context, req *taskstore.UpdateRequest) (taskstore.TaskVersion, error)
GetFunc func(ctx context.Context, taskID a2a.TaskID) (*taskstore.StoredTask, error)
}
TestTaskStore is a mock of TaskStore
func NewTestTaskStore ¶
func NewTestTaskStore() *TestTaskStore
NewTestTaskStore invokes NewTestTaskStoreWithConfig with nil to use the default config.
func NewTestTaskStoreWithConfig ¶
func NewTestTaskStoreWithConfig(config *taskstore.InMemoryStoreConfig) *TestTaskStore
NewTestTaskStoreWithConfig allows to mock execution of task store operations. Without any overrides it defaults to in memory implementation with given config.
func (*TestTaskStore) Create ¶
func (m *TestTaskStore) Create(ctx context.Context, task *a2a.Task) (taskstore.TaskVersion, error)
Create implements taskstore.TaskStore interface.
func (*TestTaskStore) Get ¶
func (m *TestTaskStore) Get(ctx context.Context, taskID a2a.TaskID) (*taskstore.StoredTask, error)
Get implements taskstore.TaskStore interface.
func (*TestTaskStore) SetGetOverride ¶
func (m *TestTaskStore) SetGetOverride(task *taskstore.StoredTask, err error) *TestTaskStore
SetGetOverride overrides Get execution
func (*TestTaskStore) SetSaveError ¶
func (m *TestTaskStore) SetSaveError(err error) *TestTaskStore
SetSaveError overrides Save execution with given error
func (*TestTaskStore) Update ¶
func (m *TestTaskStore) Update(ctx context.Context, req *taskstore.UpdateRequest) (taskstore.TaskVersion, error)
Update implements taskstore.TaskStore interface.
func (*TestTaskStore) WithTasks ¶
func (m *TestTaskStore) WithTasks(t *testing.T, tasks ...*a2a.Task) *TestTaskStore
WithTasks seeds TaskStore with given tasks
type TestWorkQueue ¶ added in v0.3.4
type TestWorkQueue struct {
HandlerFn workqueue.HandlerFn
Payloads []*workqueue.Payload
WriteErr error
WriteFunc func(context.Context, *workqueue.Payload) (a2a.TaskID, error)
RegisterHandlerFunc func(workqueue.HandlerConfig, workqueue.HandlerFn)
}
TestWorkQueue is a mock of workqueue.Queue.
func NewTestWorkQueue ¶ added in v0.3.4
func NewTestWorkQueue() *TestWorkQueue
NewTestWorkQueue allows to mock execution of work queue operations. Without any overrides it defaults to in memory implementation.
func (*TestWorkQueue) RegisterHandler ¶ added in v0.3.4
func (m *TestWorkQueue) RegisterHandler(cfg workqueue.HandlerConfig, fn workqueue.HandlerFn)
RegisterHandler implements workqueue.Queue interface.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package testexecutor provides mock implementations for agent executor for testing.
|
Package testexecutor provides mock implementations for agent executor for testing. |