Documentation
¶
Overview ¶
Package testkit provides testing utilities for Weave.
Index ¶
- type MockBroker
- func (m *MockBroker) AssertNotPublished(t testing.TB, destination string)
- func (m *MockBroker) AssertPublishCount(t testing.TB, destination string, expected int)
- func (m *MockBroker) AssertPublished(t testing.TB, destination string)
- func (m *MockBroker) Backend() string
- func (m *MockBroker) Call(ctx context.Context, destination string, msg *core.Message, ...) (*core.Message, error)
- func (m *MockBroker) Close() error
- func (m *MockBroker) Connect(ctx context.Context) error
- func (m *MockBroker) HasSubscription(destination string) bool
- func (m *MockBroker) IsConnected() bool
- func (m *MockBroker) IsRecovering() bool
- func (m *MockBroker) Publish(ctx context.Context, destination string, msg *core.Message, ...) error
- func (m *MockBroker) PublishedMessages() []PublishedMessage
- func (m *MockBroker) PublishedTo(destination string) []PublishedMessage
- func (m *MockBroker) Reset()
- func (m *MockBroker) SetCallError(destination string, err error)
- func (m *MockBroker) SetCallResponse(destination string, response *core.Message)
- func (m *MockBroker) SimulateMessage(ctx context.Context, destination string, msg *core.Message) error
- func (m *MockBroker) Subscribe(ctx context.Context, destination string, handler core.Handler, ...) error
- func (m *MockBroker) Subscriptions() []string
- type PublishedMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockBroker ¶
type MockBroker struct {
// contains filtered or unexported fields
}
MockBroker is a mock implementation of core.MessageBroker for testing. It can be used to test both client and server code.
func (*MockBroker) AssertNotPublished ¶
func (m *MockBroker) AssertNotPublished(t testing.TB, destination string)
AssertNotPublished verifies no message was published to a destination.
func (*MockBroker) AssertPublishCount ¶
func (m *MockBroker) AssertPublishCount(t testing.TB, destination string, expected int)
AssertPublishCount verifies the number of messages published to a destination.
func (*MockBroker) AssertPublished ¶
func (m *MockBroker) AssertPublished(t testing.TB, destination string)
AssertPublished verifies a message was published to a destination.
func (*MockBroker) Backend ¶
func (m *MockBroker) Backend() string
func (*MockBroker) Close ¶
func (m *MockBroker) Close() error
func (*MockBroker) HasSubscription ¶
func (m *MockBroker) HasSubscription(destination string) bool
HasSubscription returns true if the destination has been subscribed to.
func (*MockBroker) IsConnected ¶
func (m *MockBroker) IsConnected() bool
func (*MockBroker) IsRecovering ¶
func (m *MockBroker) IsRecovering() bool
func (*MockBroker) Publish ¶
func (m *MockBroker) Publish(ctx context.Context, destination string, msg *core.Message, opts ...core.PublishOption) error
func (*MockBroker) PublishedMessages ¶
func (m *MockBroker) PublishedMessages() []PublishedMessage
PublishedMessages returns all published messages.
func (*MockBroker) PublishedTo ¶
func (m *MockBroker) PublishedTo(destination string) []PublishedMessage
PublishedTo returns messages published to a specific destination.
func (*MockBroker) Reset ¶
func (m *MockBroker) Reset()
Reset clears all recorded messages and call responses.
func (*MockBroker) SetCallError ¶
func (m *MockBroker) SetCallError(destination string, err error)
SetCallError sets an error response for Call on a destination.
func (*MockBroker) SetCallResponse ¶
func (m *MockBroker) SetCallResponse(destination string, response *core.Message)
SetCallResponse sets a mock response for Call on a destination.
func (*MockBroker) SimulateMessage ¶
func (m *MockBroker) SimulateMessage(ctx context.Context, destination string, msg *core.Message) error
SimulateMessage simulates receiving a message on a subscribed destination.
func (*MockBroker) Subscribe ¶
func (m *MockBroker) Subscribe(ctx context.Context, destination string, handler core.Handler, opts ...core.SubscribeOption) error
func (*MockBroker) Subscriptions ¶
func (m *MockBroker) Subscriptions() []string
Subscriptions returns the destinations that have been subscribed to.
type PublishedMessage ¶
PublishedMessage records a message that was published.