Documentation
¶
Overview ¶
Package mocksearch provides moq-generated mocks for the search/text package.
Index ¶
- type IndexMock
- func (mock *IndexMock[T]) Delete(ctx context.Context, id string) error
- func (mock *IndexMock[T]) DeleteCalls() []struct{ ... }
- func (mock *IndexMock[T]) Index(ctx context.Context, id string, value any) error
- func (mock *IndexMock[T]) IndexCalls() []struct{ ... }
- func (mock *IndexMock[T]) Search(ctx context.Context, query string) ([]*T, error)
- func (mock *IndexMock[T]) SearchCalls() []struct{ ... }
- func (mock *IndexMock[T]) Wipe(ctx context.Context) error
- func (mock *IndexMock[T]) WipeCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IndexMock ¶
type IndexMock[T any] struct { // DeleteFunc mocks the Delete method. DeleteFunc func(ctx context.Context, id string) error // IndexFunc mocks the Index method. IndexFunc func(ctx context.Context, id string, value any) error // SearchFunc mocks the Search method. SearchFunc func(ctx context.Context, query string) ([]*T, error) // WipeFunc mocks the Wipe method. WipeFunc func(ctx context.Context) error // contains filtered or unexported fields }
IndexMock is a mock implementation of textsearch.Index.
func TestSomethingThatUsesIndex(t *testing.T) {
// make and configure a mocked textsearch.Index
mockedIndex := &IndexMock{
DeleteFunc: func(ctx context.Context, id string) error {
panic("mock out the Delete method")
},
IndexFunc: func(ctx context.Context, id string, value any) error {
panic("mock out the Index method")
},
SearchFunc: func(ctx context.Context, query string) ([]*T, error) {
panic("mock out the Search method")
},
WipeFunc: func(ctx context.Context) error {
panic("mock out the Wipe method")
},
}
// use mockedIndex in code that requires textsearch.Index
// and then make assertions.
}
func (*IndexMock[T]) DeleteCalls ¶
DeleteCalls gets all the calls that were made to Delete. Check the length with:
len(mockedIndex.DeleteCalls())
func (*IndexMock[T]) IndexCalls ¶
IndexCalls gets all the calls that were made to Index. Check the length with:
len(mockedIndex.IndexCalls())
func (*IndexMock[T]) SearchCalls ¶
SearchCalls gets all the calls that were made to Search. Check the length with:
len(mockedIndex.SearchCalls())
Click to show internal directories.
Click to hide internal directories.