Documentation
¶
Index ¶
- type Hasher
- type HasherMock
- type InvalidConfigError
- type NewReceiverer
- type NewReceivererMock
- type NextFn
- type Receiver
- type ReceiverMock
- func (mock *ReceiverMock) Config() interface{}
- func (mock *ReceiverMock) ConfigCalls() []struct{}
- func (mock *ReceiverMock) Name() string
- func (mock *ReceiverMock) NameCalls() []struct{}
- func (mock *ReceiverMock) Plugin() string
- func (mock *ReceiverMock) PluginCalls() []struct{}
- func (mock *ReceiverMock) Receive(next NextFn) error
- func (mock *ReceiverMock) ReceiveCalls() []struct{ ... }
- func (mock *ReceiverMock) StopReceiving(ctx context.Context) error
- func (mock *ReceiverMock) StopReceivingCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hasher ¶
type Hasher interface {
// ReceiverHash calculates the hash of a receiver based on the
// given configuration
ReceiverHash(config interface{}) (string, error)
}
Hasher defines the hashing interface that a receiver needs to implement
type HasherMock ¶
type HasherMock struct {
// ReceiverHashFunc mocks the ReceiverHash method.
ReceiverHashFunc func(config interface{}) (string, error)
// contains filtered or unexported fields
}
HasherMock is a mock implementation of Hasher.
func TestSomethingThatUsesHasher(t *testing.T) {
// make and configure a mocked Hasher
mockedHasher := &HasherMock{
ReceiverHashFunc: func(config interface{}) (string, error) {
panic("mock out the ReceiverHash method")
},
}
// use mockedHasher in code that requires Hasher
// and then make assertions.
}
func (*HasherMock) ReceiverHash ¶
func (mock *HasherMock) ReceiverHash(config interface{}) (string, error)
ReceiverHash calls ReceiverHashFunc.
func (*HasherMock) ReceiverHashCalls ¶
func (mock *HasherMock) ReceiverHashCalls() []struct { Config interface{} }
ReceiverHashCalls gets all the calls that were made to ReceiverHash. Check the length with:
len(mockedHasher.ReceiverHashCalls())
type InvalidConfigError ¶
type InvalidConfigError struct {
Err error
}
InvalidConfigError is returned when a bad configuration is passed into the New* functions
func (*InvalidConfigError) Error ¶
func (e *InvalidConfigError) Error() string
func (*InvalidConfigError) Unwrap ¶
func (e *InvalidConfigError) Unwrap() error
type NewReceiverer ¶
type NewReceivererMock ¶
type NewReceivererMock struct {
// NewReceiverFunc mocks the NewReceiver method.
NewReceiverFunc func(config interface{}) (Receiver, error)
// ReceiverHashFunc mocks the ReceiverHash method.
ReceiverHashFunc func(config interface{}) (string, error)
// contains filtered or unexported fields
}
NewReceivererMock is a mock implementation of NewReceiverer.
func TestSomethingThatUsesNewReceiverer(t *testing.T) {
// make and configure a mocked NewReceiverer
mockedNewReceiverer := &NewReceivererMock{
NewReceiverFunc: func(config interface{}) (Receiver, error) {
panic("mock out the NewReceiver method")
},
ReceiverHashFunc: func(config interface{}) (string, error) {
panic("mock out the ReceiverHash method")
},
}
// use mockedNewReceiverer in code that requires NewReceiverer
// and then make assertions.
}
func (*NewReceivererMock) NewReceiver ¶
func (mock *NewReceivererMock) NewReceiver(config interface{}) (Receiver, error)
NewReceiver calls NewReceiverFunc.
func (*NewReceivererMock) NewReceiverCalls ¶
func (mock *NewReceivererMock) NewReceiverCalls() []struct { Config interface{} }
NewReceiverCalls gets all the calls that were made to NewReceiver. Check the length with:
len(mockedNewReceiverer.NewReceiverCalls())
func (*NewReceivererMock) ReceiverHash ¶
func (mock *NewReceivererMock) ReceiverHash(config interface{}) (string, error)
ReceiverHash calls ReceiverHashFunc.
func (*NewReceivererMock) ReceiverHashCalls ¶
func (mock *NewReceivererMock) ReceiverHashCalls() []struct { Config interface{} }
ReceiverHashCalls gets all the calls that were made to ReceiverHash. Check the length with:
len(mockedNewReceiverer.ReceiverHashCalls())
type Receiver ¶
type Receiver interface {
Receive(next NextFn) error
// StopReceiving will stop the receiver from receiving events.
// This will cause Receive to return.
StopReceiving(ctx context.Context) error
//
//
Config() interface{}
Name() string
Plugin() string
}
Receiver is a plugin that will receive messages and will send them to `NextFn`
type ReceiverMock ¶
type ReceiverMock struct {
// ConfigFunc mocks the Config method.
ConfigFunc func() interface{}
// NameFunc mocks the Name method.
NameFunc func() string
// PluginFunc mocks the Plugin method.
PluginFunc func() string
// ReceiveFunc mocks the Receive method.
ReceiveFunc func(next NextFn) error
// StopReceivingFunc mocks the StopReceiving method.
StopReceivingFunc func(ctx context.Context) error
// contains filtered or unexported fields
}
ReceiverMock is a mock implementation of Receiver.
func TestSomethingThatUsesReceiver(t *testing.T) {
// make and configure a mocked Receiver
mockedReceiver := &ReceiverMock{
ConfigFunc: func() interface{} {
panic("mock out the Config method")
},
NameFunc: func() string {
panic("mock out the Name method")
},
PluginFunc: func() string {
panic("mock out the Plugin method")
},
ReceiveFunc: func(next NextFn) error {
panic("mock out the Receive method")
},
StopReceivingFunc: func(ctx context.Context) error {
panic("mock out the StopReceiving method")
},
}
// use mockedReceiver in code that requires Receiver
// and then make assertions.
}
func (*ReceiverMock) Config ¶ added in v0.2.1
func (mock *ReceiverMock) Config() interface{}
Config calls ConfigFunc.
func (*ReceiverMock) ConfigCalls ¶ added in v0.2.1
func (mock *ReceiverMock) ConfigCalls() []struct { }
ConfigCalls gets all the calls that were made to Config. Check the length with:
len(mockedReceiver.ConfigCalls())
func (*ReceiverMock) Name ¶ added in v0.2.1
func (mock *ReceiverMock) Name() string
Name calls NameFunc.
func (*ReceiverMock) NameCalls ¶ added in v0.2.1
func (mock *ReceiverMock) NameCalls() []struct { }
NameCalls gets all the calls that were made to Name. Check the length with:
len(mockedReceiver.NameCalls())
func (*ReceiverMock) Plugin ¶ added in v0.2.1
func (mock *ReceiverMock) Plugin() string
Plugin calls PluginFunc.
func (*ReceiverMock) PluginCalls ¶ added in v0.2.1
func (mock *ReceiverMock) PluginCalls() []struct { }
PluginCalls gets all the calls that were made to Plugin. Check the length with:
len(mockedReceiver.PluginCalls())
func (*ReceiverMock) Receive ¶
func (mock *ReceiverMock) Receive(next NextFn) error
Receive calls ReceiveFunc.
func (*ReceiverMock) ReceiveCalls ¶
func (mock *ReceiverMock) ReceiveCalls() []struct { Next NextFn }
ReceiveCalls gets all the calls that were made to Receive. Check the length with:
len(mockedReceiver.ReceiveCalls())
func (*ReceiverMock) StopReceiving ¶
func (mock *ReceiverMock) StopReceiving(ctx context.Context) error
StopReceiving calls StopReceivingFunc.
func (*ReceiverMock) StopReceivingCalls ¶
func (mock *ReceiverMock) StopReceivingCalls() []struct { Ctx context.Context }
StopReceivingCalls gets all the calls that were made to StopReceiving. Check the length with:
len(mockedReceiver.StopReceivingCalls())