testkit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package testkit provides testing utilities for Weave.

Index

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 NewMockBroker

func NewMockBroker() *MockBroker

NewMockBroker creates a new mock broker.

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) Call

func (m *MockBroker) Call(ctx context.Context, destination string, msg *core.Message, opts ...core.PublishOption) (*core.Message, error)

func (*MockBroker) Close

func (m *MockBroker) Close() error

func (*MockBroker) Connect

func (m *MockBroker) Connect(ctx context.Context) 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

type PublishedMessage struct {
	Destination string
	Message     *core.Message
}

PublishedMessage records a message that was published.

Jump to

Keyboard shortcuts

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