mock

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Overview

Package mock provides mock implementations of the embeddings package's interfaces. Both the hand-written testify-based Embedder and the moq-generated EmbedderMock live here during the testify → moq migration. New test code should prefer EmbedderMock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbedderMock

type EmbedderMock struct {
	// GenerateEmbeddingFunc mocks the GenerateEmbedding method.
	GenerateEmbeddingFunc func(ctx context.Context, input *embeddings.Input) (*embeddings.Embedding, error)
	// contains filtered or unexported fields
}

EmbedderMock is a mock implementation of embeddings.Embedder.

func TestSomethingThatUsesEmbedder(t *testing.T) {

	// make and configure a mocked embeddings.Embedder
	mockedEmbedder := &EmbedderMock{
		GenerateEmbeddingFunc: func(ctx context.Context, input *embeddings.Input) (*embeddings.Embedding, error) {
			panic("mock out the GenerateEmbedding method")
		},
	}

	// use mockedEmbedder in code that requires embeddings.Embedder
	// and then make assertions.

}

func (*EmbedderMock) GenerateEmbedding

func (mock *EmbedderMock) GenerateEmbedding(ctx context.Context, input *embeddings.Input) (*embeddings.Embedding, error)

GenerateEmbedding calls GenerateEmbeddingFunc.

func (*EmbedderMock) GenerateEmbeddingCalls

func (mock *EmbedderMock) GenerateEmbeddingCalls() []struct {
	Ctx   context.Context
	Input *embeddings.Input
}

GenerateEmbeddingCalls gets all the calls that were made to GenerateEmbedding. Check the length with:

len(mockedEmbedder.GenerateEmbeddingCalls())

Jump to

Keyboard shortcuts

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