mock

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package mock provides moq-generated mocks for the search/vector package.

Index

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]) Delete

func (mock *IndexMock[T]) Delete(ctx context.Context, ids ...string) error

Delete calls DeleteFunc.

func (*IndexMock[T]) DeleteCalls

func (mock *IndexMock[T]) DeleteCalls() []struct {
	Ctx context.Context
	Ids []string
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedIndex.DeleteCalls())

func (*IndexMock[T]) Query

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]) Upsert

func (mock *IndexMock[T]) Upsert(ctx context.Context, vectors ...vectorsearch.Vector[T]) error

Upsert calls UpsertFunc.

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())

func (*IndexMock[T]) Wipe

func (mock *IndexMock[T]) Wipe(ctx context.Context) error

Wipe calls WipeFunc.

func (*IndexMock[T]) WipeCalls

func (mock *IndexMock[T]) WipeCalls() []struct {
	Ctx context.Context
}

WipeCalls gets all the calls that were made to Wipe. Check the length with:

len(mockedIndex.WipeCalls())

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL