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())
Click to show internal directories.
Click to hide internal directories.