mocksearch

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package mocksearch provides moq-generated mocks for the search/text 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, 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]) Delete

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

Delete calls DeleteFunc.

func (*IndexMock[T]) DeleteCalls

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

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

len(mockedIndex.DeleteCalls())

func (*IndexMock[T]) Index

func (mock *IndexMock[T]) Index(ctx context.Context, id string, value any) error

Index calls IndexFunc.

func (*IndexMock[T]) IndexCalls

func (mock *IndexMock[T]) IndexCalls() []struct {
	Ctx   context.Context
	ID    string
	Value any
}

IndexCalls gets all the calls that were made to Index. Check the length with:

len(mockedIndex.IndexCalls())

func (*IndexMock[T]) Search

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

Search calls SearchFunc.

func (*IndexMock[T]) SearchCalls

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

SearchCalls gets all the calls that were made to Search. Check the length with:

len(mockedIndex.SearchCalls())

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