Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventHandler ¶
type EventHandler struct { Events []*event.ObservationExtracted Error error EventUpdated chan bool }
EventHandler provides a mock implementation that captures events to check.
func NewEventHandler ¶
func NewEventHandler() *EventHandler
NewEventHandler returns a new mock event handler to capture event
func (*EventHandler) Handle ¶
func (handler *EventHandler) Handle(ctx context.Context, events []*event.ObservationExtracted) error
Handle captures the given event and stores it for later assertions
type ObservationMapperMock ¶
type ObservationMapperMock struct { // MapFunc mocks the Map method. MapFunc func(ctx context.Context, row string, rowIndex int64, instanceID string) (*models.Observation, error) // contains filtered or unexported fields }
ObservationMapperMock is a mock implementation of event.ObservationMapper.
func TestSomethingThatUsesObservationMapper(t *testing.T) { // make and configure a mocked event.ObservationMapper mockedObservationMapper := &ObservationMapperMock{ MapFunc: func(ctx context.Context, row string, rowIndex int64, instanceID string) (*models.Observation, error) { panic("mock out the Map method") }, } // use mockedObservationMapper in code that requires event.ObservationMapper // and then make assertions. }
type ObservationStoreMock ¶
type ObservationStoreMock struct { // SaveAllFunc mocks the SaveAll method. SaveAllFunc func(ctx context.Context, observations []*models.Observation) ([]*observation.Result, error) // contains filtered or unexported fields }
ObservationStoreMock is a mock implementation of event.ObservationStore.
func TestSomethingThatUsesObservationStore(t *testing.T) { // make and configure a mocked event.ObservationStore mockedObservationStore := &ObservationStoreMock{ SaveAllFunc: func(ctx context.Context, observations []*models.Observation) ([]*observation.Result, error) { panic("mock out the SaveAll method") }, } // use mockedObservationStore in code that requires event.ObservationStore // and then make assertions. }
func (*ObservationStoreMock) SaveAll ¶
func (mock *ObservationStoreMock) SaveAll(ctx context.Context, observations []*models.Observation) ([]*observation.Result, error)
SaveAll calls SaveAllFunc.
func (*ObservationStoreMock) SaveAllCalls ¶
func (mock *ObservationStoreMock) SaveAllCalls() []struct { Ctx context.Context Observations []*models.Observation }
SaveAllCalls gets all the calls that were made to SaveAll. Check the length with:
len(mockedObservationStore.SaveAllCalls())
type ResultWriterMock ¶
type ResultWriterMock struct { // WriteFunc mocks the Write method. WriteFunc func(ctx context.Context, results []*observation.Result) // contains filtered or unexported fields }
ResultWriterMock is a mock implementation of event.ResultWriter.
func TestSomethingThatUsesResultWriter(t *testing.T) { // make and configure a mocked event.ResultWriter mockedResultWriter := &ResultWriterMock{ WriteFunc: func(ctx context.Context, results []*observation.Result) { panic("mock out the Write method") }, } // use mockedResultWriter in code that requires event.ResultWriter // and then make assertions. }
func (*ResultWriterMock) Write ¶
func (mock *ResultWriterMock) Write(ctx context.Context, results []*observation.Result)
Write calls WriteFunc.
func (*ResultWriterMock) WriteCalls ¶
func (mock *ResultWriterMock) WriteCalls() []struct { Ctx context.Context Results []*observation.Result }
WriteCalls gets all the calls that were made to Write. Check the length with:
len(mockedResultWriter.WriteCalls())