Documentation
¶
Index ¶
- type IConsumerGroupMock
- func (mock *IConsumerGroupMock) Channels() *kafka.ConsumerGroupChannels
- func (mock *IConsumerGroupMock) ChannelsCalls() []struct{}
- func (mock *IConsumerGroupMock) Checker(ctx context.Context, state *health.CheckState) error
- func (mock *IConsumerGroupMock) CheckerCalls() []struct{ ... }
- func (mock *IConsumerGroupMock) Close(ctx context.Context, optFuncs ...kafka.OptFunc) error
- func (mock *IConsumerGroupMock) CloseCalls() []struct{ ... }
- func (mock *IConsumerGroupMock) Initialise(ctx context.Context) error
- func (mock *IConsumerGroupMock) InitialiseCalls() []struct{ ... }
- func (mock *IConsumerGroupMock) IsInitialised() bool
- func (mock *IConsumerGroupMock) IsInitialisedCalls() []struct{}
- func (mock *IConsumerGroupMock) StopListeningToConsumer(ctx context.Context) error
- func (mock *IConsumerGroupMock) StopListeningToConsumerCalls() []struct{ ... }
- type IProducerMock
- func (mock *IProducerMock) AddHeader(key string, value string)
- func (mock *IProducerMock) AddHeaderCalls() []struct{ ... }
- func (mock *IProducerMock) Channels() *kafka.ProducerChannels
- func (mock *IProducerMock) ChannelsCalls() []struct{}
- func (mock *IProducerMock) Checker(ctx context.Context, state *health.CheckState) error
- func (mock *IProducerMock) CheckerCalls() []struct{ ... }
- func (mock *IProducerMock) Close(ctx context.Context) error
- func (mock *IProducerMock) CloseCalls() []struct{ ... }
- func (mock *IProducerMock) Initialise(ctx context.Context) error
- func (mock *IProducerMock) InitialiseCalls() []struct{ ... }
- func (mock *IProducerMock) IsInitialised() bool
- func (mock *IProducerMock) IsInitialisedCalls() []struct{}
- type Message
- type MessageConsumer
- type MessageMock
- func (mock *MessageMock) Commit()
- func (mock *MessageMock) CommitAndRelease()
- func (mock *MessageMock) CommitAndReleaseCalls() []struct{}
- func (mock *MessageMock) CommitCalls() []struct{}
- func (mock *MessageMock) Context() context.Context
- func (mock *MessageMock) ContextCalls() []struct{}
- func (mock *MessageMock) GetData() []byte
- func (mock *MessageMock) GetDataCalls() []struct{}
- func (mock *MessageMock) GetHeader(key string) string
- func (mock *MessageMock) GetHeaderCalls() []struct{ ... }
- func (mock *MessageMock) Mark()
- func (mock *MessageMock) MarkCalls() []struct{}
- func (mock *MessageMock) Offset() int64
- func (mock *MessageMock) OffsetCalls() []struct{}
- func (mock *MessageMock) Release()
- func (mock *MessageMock) ReleaseCalls() []struct{}
- func (mock *MessageMock) UpstreamDone() chan struct{}
- func (mock *MessageMock) UpstreamDoneCalls() []struct{}
- type MessageProducer
- type TestHeader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IConsumerGroupMock ¶
type IConsumerGroupMock struct { // ChannelsFunc mocks the Channels method. ChannelsFunc func() *kafka.ConsumerGroupChannels // CheckerFunc mocks the Checker method. CheckerFunc func(ctx context.Context, state *health.CheckState) error // CloseFunc mocks the Close method. CloseFunc func(ctx context.Context, optFuncs ...kafka.OptFunc) error // InitialiseFunc mocks the Initialise method. InitialiseFunc func(ctx context.Context) error // IsInitialisedFunc mocks the IsInitialised method. IsInitialisedFunc func() bool // StopListeningToConsumerFunc mocks the StopListeningToConsumer method. StopListeningToConsumerFunc func(ctx context.Context) error // contains filtered or unexported fields }
IConsumerGroupMock is a mock implementation of kafka.IConsumerGroup.
func TestSomethingThatUsesIConsumerGroup(t *testing.T) { // make and configure a mocked kafka.IConsumerGroup mockedIConsumerGroup := &IConsumerGroupMock{ ChannelsFunc: func() *kafka.ConsumerGroupChannels { panic("mock out the Channels method") }, CheckerFunc: func(ctx context.Context, state *health.CheckState) error { panic("mock out the Checker method") }, CloseFunc: func(ctx context.Context, optFuncs ...kafka.OptFunc) error { panic("mock out the Close method") }, InitialiseFunc: func(ctx context.Context) error { panic("mock out the Initialise method") }, IsInitialisedFunc: func() bool { panic("mock out the IsInitialised method") }, StopListeningToConsumerFunc: func(ctx context.Context) error { panic("mock out the StopListeningToConsumer method") }, } // use mockedIConsumerGroup in code that requires kafka.IConsumerGroup // and then make assertions. }
func (*IConsumerGroupMock) Channels ¶
func (mock *IConsumerGroupMock) Channels() *kafka.ConsumerGroupChannels
Channels calls ChannelsFunc.
func (*IConsumerGroupMock) ChannelsCalls ¶
func (mock *IConsumerGroupMock) ChannelsCalls() []struct { }
ChannelsCalls gets all the calls that were made to Channels. Check the length with:
len(mockedIConsumerGroup.ChannelsCalls())
func (*IConsumerGroupMock) Checker ¶
func (mock *IConsumerGroupMock) Checker(ctx context.Context, state *health.CheckState) error
Checker calls CheckerFunc.
func (*IConsumerGroupMock) CheckerCalls ¶
func (mock *IConsumerGroupMock) CheckerCalls() []struct { Ctx context.Context State *health.CheckState }
CheckerCalls gets all the calls that were made to Checker. Check the length with:
len(mockedIConsumerGroup.CheckerCalls())
func (*IConsumerGroupMock) Close ¶
func (mock *IConsumerGroupMock) Close(ctx context.Context, optFuncs ...kafka.OptFunc) error
Close calls CloseFunc.
func (*IConsumerGroupMock) CloseCalls ¶
func (mock *IConsumerGroupMock) CloseCalls() []struct { Ctx context.Context OptFuncs []kafka.OptFunc }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedIConsumerGroup.CloseCalls())
func (*IConsumerGroupMock) Initialise ¶
func (mock *IConsumerGroupMock) Initialise(ctx context.Context) error
Initialise calls InitialiseFunc.
func (*IConsumerGroupMock) InitialiseCalls ¶
func (mock *IConsumerGroupMock) InitialiseCalls() []struct { Ctx context.Context }
InitialiseCalls gets all the calls that were made to Initialise. Check the length with:
len(mockedIConsumerGroup.InitialiseCalls())
func (*IConsumerGroupMock) IsInitialised ¶
func (mock *IConsumerGroupMock) IsInitialised() bool
IsInitialised calls IsInitialisedFunc.
func (*IConsumerGroupMock) IsInitialisedCalls ¶
func (mock *IConsumerGroupMock) IsInitialisedCalls() []struct { }
IsInitialisedCalls gets all the calls that were made to IsInitialised. Check the length with:
len(mockedIConsumerGroup.IsInitialisedCalls())
func (*IConsumerGroupMock) StopListeningToConsumer ¶
func (mock *IConsumerGroupMock) StopListeningToConsumer(ctx context.Context) error
StopListeningToConsumer calls StopListeningToConsumerFunc.
func (*IConsumerGroupMock) StopListeningToConsumerCalls ¶
func (mock *IConsumerGroupMock) StopListeningToConsumerCalls() []struct { Ctx context.Context }
StopListeningToConsumerCalls gets all the calls that were made to StopListeningToConsumer. Check the length with:
len(mockedIConsumerGroup.StopListeningToConsumerCalls())
type IProducerMock ¶
type IProducerMock struct { // AddHeaderFunc mocks the AddHeader method. AddHeaderFunc func(key string, value string) // ChannelsFunc mocks the Channels method. ChannelsFunc func() *kafka.ProducerChannels // CheckerFunc mocks the Checker method. CheckerFunc func(ctx context.Context, state *health.CheckState) error // CloseFunc mocks the Close method. CloseFunc func(ctx context.Context) error // InitialiseFunc mocks the Initialise method. InitialiseFunc func(ctx context.Context) error // IsInitialisedFunc mocks the IsInitialised method. IsInitialisedFunc func() bool // contains filtered or unexported fields }
IProducerMock is a mock implementation of kafka.IProducer.
func TestSomethingThatUsesIProducer(t *testing.T) { // make and configure a mocked kafka.IProducer mockedIProducer := &IProducerMock{ AddHeaderFunc: func(key string, value string) { panic("mock out the AddHeader method") }, ChannelsFunc: func() *kafka.ProducerChannels { panic("mock out the Channels method") }, CheckerFunc: func(ctx context.Context, state *health.CheckState) error { panic("mock out the Checker method") }, CloseFunc: func(ctx context.Context) error { panic("mock out the Close method") }, InitialiseFunc: func(ctx context.Context) error { panic("mock out the Initialise method") }, IsInitialisedFunc: func() bool { panic("mock out the IsInitialised method") }, } // use mockedIProducer in code that requires kafka.IProducer // and then make assertions. }
func (*IProducerMock) AddHeader ¶ added in v2.7.1
func (mock *IProducerMock) AddHeader(key string, value string)
AddHeader calls AddHeaderFunc.
func (*IProducerMock) AddHeaderCalls ¶ added in v2.7.1
func (mock *IProducerMock) AddHeaderCalls() []struct { Key string Value string }
AddHeaderCalls gets all the calls that were made to AddHeader. Check the length with:
len(mockedIProducer.AddHeaderCalls())
func (*IProducerMock) Channels ¶
func (mock *IProducerMock) Channels() *kafka.ProducerChannels
Channels calls ChannelsFunc.
func (*IProducerMock) ChannelsCalls ¶
func (mock *IProducerMock) ChannelsCalls() []struct { }
ChannelsCalls gets all the calls that were made to Channels. Check the length with:
len(mockedIProducer.ChannelsCalls())
func (*IProducerMock) Checker ¶
func (mock *IProducerMock) Checker(ctx context.Context, state *health.CheckState) error
Checker calls CheckerFunc.
func (*IProducerMock) CheckerCalls ¶
func (mock *IProducerMock) CheckerCalls() []struct { Ctx context.Context State *health.CheckState }
CheckerCalls gets all the calls that were made to Checker. Check the length with:
len(mockedIProducer.CheckerCalls())
func (*IProducerMock) Close ¶
func (mock *IProducerMock) Close(ctx context.Context) error
Close calls CloseFunc.
func (*IProducerMock) CloseCalls ¶
func (mock *IProducerMock) CloseCalls() []struct { Ctx context.Context }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedIProducer.CloseCalls())
func (*IProducerMock) Initialise ¶
func (mock *IProducerMock) Initialise(ctx context.Context) error
Initialise calls InitialiseFunc.
func (*IProducerMock) InitialiseCalls ¶
func (mock *IProducerMock) InitialiseCalls() []struct { Ctx context.Context }
InitialiseCalls gets all the calls that were made to Initialise. Check the length with:
len(mockedIProducer.InitialiseCalls())
func (*IProducerMock) IsInitialised ¶
func (mock *IProducerMock) IsInitialised() bool
IsInitialised calls IsInitialisedFunc.
func (*IProducerMock) IsInitialisedCalls ¶
func (mock *IProducerMock) IsInitialisedCalls() []struct { }
IsInitialisedCalls gets all the calls that were made to IsInitialised. Check the length with:
len(mockedIProducer.IsInitialisedCalls())
type Message ¶
type Message struct { *MessageMock // contains filtered or unexported fields }
Message allows a mock message to return the configured data, and capture whether commit has been called.
func NewMessage ¶
func NewMessage(data []byte, offset int64, hValue ...TestHeader) *Message
NewMessage returns a new mock message containing the given data.
func (Message) ContextFunc ¶ added in v2.7.1
Context returns a context with traceid.
func (Message) GetHeaderFunc ¶ added in v2.7.1
GetHeader takes a key for the header and returns the value if the key exist in the header.
func (Message) IsCommitted ¶ added in v2.1.0
func (internal Message) IsCommitted() bool
IsCommittedFunc returns true if the message offset was committed.
type MessageConsumer ¶
type MessageConsumer struct { *IConsumerGroupMock // contains filtered or unexported fields }
MessageConsumer is an extension of the moq ConsumerGroup, with channels and implementation of required functions to emulate a fully functional Kafka ConsumerGroup
func NewMessageConsumer ¶
func NewMessageConsumer(isInitialisedAtCreationTime bool) *MessageConsumer
NewMessageConsumer creates a testing consumer with new consumerGroupChannels. isInitialisedAtCreationTime determines if the consumer is initialised or not when it's created
func NewMessageConsumerWithChannels ¶
func NewMessageConsumerWithChannels(cgChannels *kafka.ConsumerGroupChannels, isInitialisedAtCreationTime bool) *MessageConsumer
NewMessageConsumerWithChannels creates a testing consumer with the provided consumerGroupChannels isInitialisedAtCreationTime determines if the consumer is initialised or not when it's created
type MessageMock ¶
type MessageMock struct { // CommitFunc mocks the Commit method. CommitFunc func() // CommitAndReleaseFunc mocks the CommitAndRelease method. CommitAndReleaseFunc func() // ContextFunc mocks the Context method. ContextFunc func() context.Context // GetDataFunc mocks the GetData method. GetDataFunc func() []byte // GetHeaderFunc mocks the GetHeader method. GetHeaderFunc func(key string) string // MarkFunc mocks the Mark method. MarkFunc func() // OffsetFunc mocks the Offset method. OffsetFunc func() int64 // ReleaseFunc mocks the Release method. ReleaseFunc func() // UpstreamDoneFunc mocks the UpstreamDone method. UpstreamDoneFunc func() chan struct{} // contains filtered or unexported fields }
MessageMock is a mock implementation of kafka.Message.
func TestSomethingThatUsesMessage(t *testing.T) { // make and configure a mocked kafka.Message mockedMessage := &MessageMock{ CommitFunc: func() { panic("mock out the Commit method") }, CommitAndReleaseFunc: func() { panic("mock out the CommitAndRelease method") }, ContextFunc: func() context.Context { panic("mock out the Context method") }, GetDataFunc: func() []byte { panic("mock out the GetData method") }, GetHeaderFunc: func(key string) string { panic("mock out the GetHeader method") }, MarkFunc: func() { panic("mock out the Mark method") }, OffsetFunc: func() int64 { panic("mock out the Offset method") }, ReleaseFunc: func() { panic("mock out the Release method") }, UpstreamDoneFunc: func() chan struct{} { panic("mock out the UpstreamDone method") }, } // use mockedMessage in code that requires kafka.Message // and then make assertions. }
func (*MessageMock) CommitAndRelease ¶ added in v2.1.0
func (mock *MessageMock) CommitAndRelease()
CommitAndRelease calls CommitAndReleaseFunc.
func (*MessageMock) CommitAndReleaseCalls ¶ added in v2.1.0
func (mock *MessageMock) CommitAndReleaseCalls() []struct { }
CommitAndReleaseCalls gets all the calls that were made to CommitAndRelease. Check the length with:
len(mockedMessage.CommitAndReleaseCalls())
func (*MessageMock) CommitCalls ¶
func (mock *MessageMock) CommitCalls() []struct { }
CommitCalls gets all the calls that were made to Commit. Check the length with:
len(mockedMessage.CommitCalls())
func (*MessageMock) Context ¶ added in v2.6.0
func (mock *MessageMock) Context() context.Context
Context calls ContextFunc.
func (*MessageMock) ContextCalls ¶ added in v2.6.0
func (mock *MessageMock) ContextCalls() []struct { }
ContextCalls gets all the calls that were made to Context. Check the length with:
len(mockedMessage.ContextCalls())
func (*MessageMock) GetDataCalls ¶
func (mock *MessageMock) GetDataCalls() []struct { }
GetDataCalls gets all the calls that were made to GetData. Check the length with:
len(mockedMessage.GetDataCalls())
func (*MessageMock) GetHeader ¶ added in v2.6.0
func (mock *MessageMock) GetHeader(key string) string
GetHeader calls GetHeaderFunc.
func (*MessageMock) GetHeaderCalls ¶ added in v2.6.0
func (mock *MessageMock) GetHeaderCalls() []struct { Key string }
GetHeaderCalls gets all the calls that were made to GetHeader. Check the length with:
len(mockedMessage.GetHeaderCalls())
func (*MessageMock) MarkCalls ¶ added in v2.1.0
func (mock *MessageMock) MarkCalls() []struct { }
MarkCalls gets all the calls that were made to Mark. Check the length with:
len(mockedMessage.MarkCalls())
func (*MessageMock) OffsetCalls ¶
func (mock *MessageMock) OffsetCalls() []struct { }
OffsetCalls gets all the calls that were made to Offset. Check the length with:
len(mockedMessage.OffsetCalls())
func (*MessageMock) Release ¶ added in v2.1.0
func (mock *MessageMock) Release()
Release calls ReleaseFunc.
func (*MessageMock) ReleaseCalls ¶ added in v2.1.0
func (mock *MessageMock) ReleaseCalls() []struct { }
ReleaseCalls gets all the calls that were made to Release. Check the length with:
len(mockedMessage.ReleaseCalls())
func (*MessageMock) UpstreamDone ¶
func (mock *MessageMock) UpstreamDone() chan struct{}
UpstreamDone calls UpstreamDoneFunc.
func (*MessageMock) UpstreamDoneCalls ¶
func (mock *MessageMock) UpstreamDoneCalls() []struct { }
UpstreamDoneCalls gets all the calls that were made to UpstreamDone. Check the length with:
len(mockedMessage.UpstreamDoneCalls())
type MessageProducer ¶
type MessageProducer struct { *IProducerMock // contains filtered or unexported fields }
MessageProducer is an extension of the moq Producer, with channels and implementation of required functions to emulate a fully functional kafka Producer.
func NewMessageProducer ¶
func NewMessageProducer(isInitialisedAtCreationTime bool) *MessageProducer
NewMessageProducer creates a testing producer with new producerChannels. isInitialisedAtCreationTime determines if the producer is initialised or not when it's created
func NewMessageProducerWithChannels ¶
func NewMessageProducerWithChannels(pChannels *kafka.ProducerChannels, isInitialisedAtCreationTime bool) *MessageProducer
NewMessageProducerWithChannels creates a testing producer with the provided producerChannels. isInitialisedAtCreationTime determines if the producer is initialised or not when it's created
func (MessageProducer) AddHeaderFunc ¶ added in v2.7.3
func (internal MessageProducer) AddHeaderFunc(key, value string)