Documentation ¶
Index ¶
- type Mediator
- type MediatorMock
- func (mock *MediatorMock) Publish(ctx context.Context, message Message)
- func (mock *MediatorMock) PublishCalls() []struct{ ... }
- func (mock *MediatorMock) Register(subscriber Subscriber)
- func (mock *MediatorMock) RegisterCalls() []struct{ ... }
- func (mock *MediatorMock) Start(ctx context.Context)
- func (mock *MediatorMock) StartCalls() []struct{ ... }
- func (mock *MediatorMock) SubscriberCount() int
- func (mock *MediatorMock) SubscriberCountCalls() []struct{}
- func (mock *MediatorMock) Unregister(subscriber Subscriber)
- func (mock *MediatorMock) UnregisterCalls() []struct{ ... }
- type Message
- type Subscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mediator ¶
type Mediator interface { Register(subscriber Subscriber) Unregister(subscriber Subscriber) Publish(ctx context.Context, message Message) Start(ctx context.Context) SubscriberCount() int }
type MediatorMock ¶
type MediatorMock struct { // PublishFunc mocks the Publish method. PublishFunc func(ctx context.Context, message Message) // RegisterFunc mocks the Register method. RegisterFunc func(subscriber Subscriber) // StartFunc mocks the Start method. StartFunc func(ctx context.Context) // SubscriberCountFunc mocks the SubscriberCount method. SubscriberCountFunc func() int // UnregisterFunc mocks the Unregister method. UnregisterFunc func(subscriber Subscriber) // contains filtered or unexported fields }
MediatorMock is a mock implementation of Mediator.
func TestSomethingThatUsesMediator(t *testing.T) { // make and configure a mocked Mediator mockedMediator := &MediatorMock{ PublishFunc: func(ctx context.Context, message Message) { panic("mock out the Publish method") }, RegisterFunc: func(subscriber Subscriber) { panic("mock out the Register method") }, StartFunc: func(ctx context.Context) { panic("mock out the Start method") }, SubscriberCountFunc: func() int { panic("mock out the SubscriberCount method") }, UnregisterFunc: func(subscriber Subscriber) { panic("mock out the Unregister method") }, } // use mockedMediator in code that requires Mediator // and then make assertions. }
func (*MediatorMock) Publish ¶
func (mock *MediatorMock) Publish(ctx context.Context, message Message)
Publish calls PublishFunc.
func (*MediatorMock) PublishCalls ¶
func (mock *MediatorMock) PublishCalls() []struct { Ctx context.Context Message Message }
PublishCalls gets all the calls that were made to Publish. Check the length with:
len(mockedMediator.PublishCalls())
func (*MediatorMock) Register ¶
func (mock *MediatorMock) Register(subscriber Subscriber)
Register calls RegisterFunc.
func (*MediatorMock) RegisterCalls ¶
func (mock *MediatorMock) RegisterCalls() []struct { Subscriber Subscriber }
RegisterCalls gets all the calls that were made to Register. Check the length with:
len(mockedMediator.RegisterCalls())
func (*MediatorMock) Start ¶
func (mock *MediatorMock) Start(ctx context.Context)
Start calls StartFunc.
func (*MediatorMock) StartCalls ¶
func (mock *MediatorMock) StartCalls() []struct { Ctx context.Context }
StartCalls gets all the calls that were made to Start. Check the length with:
len(mockedMediator.StartCalls())
func (*MediatorMock) SubscriberCount ¶
func (mock *MediatorMock) SubscriberCount() int
SubscriberCount calls SubscriberCountFunc.
func (*MediatorMock) SubscriberCountCalls ¶
func (mock *MediatorMock) SubscriberCountCalls() []struct { }
SubscriberCountCalls gets all the calls that were made to SubscriberCount. Check the length with:
len(mockedMediator.SubscriberCountCalls())
func (*MediatorMock) Unregister ¶
func (mock *MediatorMock) Unregister(subscriber Subscriber)
Unregister calls UnregisterFunc.
func (*MediatorMock) UnregisterCalls ¶
func (mock *MediatorMock) UnregisterCalls() []struct { Subscriber Subscriber }
UnregisterCalls gets all the calls that were made to Unregister. Check the length with:
len(mockedMediator.UnregisterCalls())
type Message ¶
type Subscriber ¶
type Subscriber interface { ID() string Tenants() []string Mailbox() chan Message Handle(m Message) bool }
func NewSubscriber ¶
func NewSubscriber(tenants []string) Subscriber