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) (a2a.Event, a2a.TaskVersion, 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 a2a.TaskVersion, err error) *TestEventQueue
- func (m *TestEventQueue) SetWriteError(err error) *TestEventQueue
- func (m *TestEventQueue) Write(ctx context.Context, event a2a.Event) error
- func (m *TestEventQueue) WriteVersioned(ctx context.Context, event a2a.Event, version a2a.TaskVersion) 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) Destroy(ctx context.Context, taskID a2a.TaskID) error
- func (m *TestQueueManager) Get(ctx context.Context, taskID a2a.TaskID) (eventqueue.Queue, bool)
- func (m *TestQueueManager) GetOrCreate(ctx context.Context, taskID a2a.TaskID) (eventqueue.Queue, error)
- func (m *TestQueueManager) SetDestroyError(err error) *TestQueueManager
- func (m *TestQueueManager) SetGetOrCreateOverride(queue eventqueue.Queue, err error) *TestQueueManager
- func (m *TestQueueManager) SetGetOverride(queue eventqueue.Queue, ok bool) *TestQueueManager
- type TestTaskStore
- func (m *TestTaskStore) Get(ctx context.Context, taskID a2a.TaskID) (*a2a.Task, a2a.TaskVersion, error)
- func (m *TestTaskStore) Save(ctx context.Context, task *a2a.Task, event a2a.Event, version a2a.TaskVersion) (a2a.TaskVersion, error)
- func (m *TestTaskStore) SetGetOverride(task *a2a.Task, version a2a.TaskVersion, err error) *TestTaskStore
- func (m *TestTaskStore) SetSaveError(err error) *TestTaskStore
- 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) (a2a.Event, a2a.TaskVersion, error)
WriteFunc func(ctx context.Context, event a2a.Event, version a2a.TaskVersion) 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
func (*TestEventQueue) Read ¶
func (m *TestEventQueue) Read(ctx context.Context) (a2a.Event, a2a.TaskVersion, error)
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 a2a.TaskVersion, err error) *TestEventQueue
SetReadOverride 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) WriteVersioned ¶ added in v0.3.4
func (m *TestEventQueue) WriteVersioned(ctx context.Context, event a2a.Event, version a2a.TaskVersion) error
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) Get ¶
func (m *TestPushConfigStore) Get(ctx context.Context, taskID a2a.TaskID, configID string) (*a2a.PushConfig, error)
func (*TestPushConfigStore) List ¶
func (m *TestPushConfigStore) List(ctx context.Context, taskID a2a.TaskID) ([]*a2a.PushConfig, error)
func (*TestPushConfigStore) Save ¶
func (m *TestPushConfigStore) Save(ctx context.Context, taskID a2a.TaskID, config *a2a.PushConfig) (*a2a.PushConfig, error)
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
GetOrCreateFunc func(ctx context.Context, taskID a2a.TaskID) (eventqueue.Queue, error)
GetFunc func(ctx context.Context, taskID a2a.TaskID) (eventqueue.Queue, bool)
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) Get ¶
func (m *TestQueueManager) Get(ctx context.Context, taskID a2a.TaskID) (eventqueue.Queue, bool)
func (*TestQueueManager) GetOrCreate ¶
func (m *TestQueueManager) GetOrCreate(ctx context.Context, taskID a2a.TaskID) (eventqueue.Queue, error)
func (*TestQueueManager) SetDestroyError ¶
func (m *TestQueueManager) SetDestroyError(err error) *TestQueueManager
SetDestroyError overrides Destroy execution with given error
func (*TestQueueManager) SetGetOrCreateOverride ¶
func (m *TestQueueManager) SetGetOrCreateOverride(queue eventqueue.Queue, err error) *TestQueueManager
SetGetOrCreateOverride overrides GetOrCreate execution
func (*TestQueueManager) SetGetOverride ¶
func (m *TestQueueManager) SetGetOverride(queue eventqueue.Queue, ok bool) *TestQueueManager
SetGetOverride overrides Get execution
type TestTaskStore ¶
type TestTaskStore struct {
*taskstore.Mem
SaveFunc func(ctx context.Context, task *a2a.Task, event a2a.Event, version a2a.TaskVersion) (a2a.TaskVersion, error)
GetFunc func(ctx context.Context, taskID a2a.TaskID) (*a2a.Task, a2a.TaskVersion, error)
}
TestTaskStore is a mock of TaskStore
func NewTestTaskStore ¶
func NewTestTaskStore() *TestTaskStore
NewTestTaskStore allows to mock execution of task store operations. Without any overrides it defaults to in memory implementation.
func (*TestTaskStore) Get ¶
func (m *TestTaskStore) Get(ctx context.Context, taskID a2a.TaskID) (*a2a.Task, a2a.TaskVersion, error)
func (*TestTaskStore) Save ¶
func (m *TestTaskStore) Save(ctx context.Context, task *a2a.Task, event a2a.Event, version a2a.TaskVersion) (a2a.TaskVersion, error)
func (*TestTaskStore) SetGetOverride ¶
func (m *TestTaskStore) SetGetOverride(task *a2a.Task, version a2a.TaskVersion, 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) 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(limiter.ConcurrencyConfig, workqueue.HandlerFn)
}
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 limiter.ConcurrencyConfig, fn workqueue.HandlerFn)