Documentation
¶
Overview ¶
Package mock provides moq-generated mocks for the search/vector package.
Index ¶
- type IndexMock
- func (mock *IndexMock[T]) Delete(ctx context.Context, ids ...string) error
- func (mock *IndexMock[T]) DeleteCalls() []struct{ ... }
- func (mock *IndexMock[T]) Query(ctx context.Context, req vectorsearch.QueryRequest) ([]vectorsearch.QueryResult[T], error)
- func (mock *IndexMock[T]) QueryCalls() []struct{ ... }
- func (mock *IndexMock[T]) Upsert(ctx context.Context, vectors ...vectorsearch.Vector[T]) error
- func (mock *IndexMock[T]) UpsertCalls() []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, ids ...string) error // QueryFunc mocks the Query method. QueryFunc func(ctx context.Context, req vectorsearch.QueryRequest) ([]vectorsearch.QueryResult[T], error) // UpsertFunc mocks the Upsert method. UpsertFunc func(ctx context.Context, vectors ...vectorsearch.Vector[T]) error // WipeFunc mocks the Wipe method. WipeFunc func(ctx context.Context) error // contains filtered or unexported fields }
IndexMock is a mock implementation of vectorsearch.Index.
func TestSomethingThatUsesIndex(t *testing.T) {
// make and configure a mocked vectorsearch.Index
mockedIndex := &IndexMock{
DeleteFunc: func(ctx context.Context, ids ...string) error {
panic("mock out the Delete method")
},
QueryFunc: func(ctx context.Context, req vectorsearch.QueryRequest) ([]vectorsearch.QueryResult[T], error) {
panic("mock out the Query method")
},
UpsertFunc: func(ctx context.Context, vectors ...vectorsearch.Vector[T]) error {
panic("mock out the Upsert method")
},
WipeFunc: func(ctx context.Context) error {
panic("mock out the Wipe method")
},
}
// use mockedIndex in code that requires vectorsearch.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]) Query ¶
func (mock *IndexMock[T]) Query(ctx context.Context, req vectorsearch.QueryRequest) ([]vectorsearch.QueryResult[T], error)
Query calls QueryFunc.
func (*IndexMock[T]) QueryCalls ¶
func (mock *IndexMock[T]) QueryCalls() []struct { Ctx context.Context Req vectorsearch.QueryRequest }
QueryCalls gets all the calls that were made to Query. Check the length with:
len(mockedIndex.QueryCalls())
func (*IndexMock[T]) UpsertCalls ¶
func (mock *IndexMock[T]) UpsertCalls() []struct { Ctx context.Context Vectors []vectorsearch.Vector[T] }
UpsertCalls gets all the calls that were made to Upsert. Check the length with:
len(mockedIndex.UpsertCalls())
Click to show internal directories.
Click to hide internal directories.