Documentation
¶
Overview ¶
Package mock provides mock implementations of the llm package's interfaces. Both the hand-written testify-based Provider and the moq-generated ProviderMock live here during the testify → moq migration. New test code should prefer ProviderMock.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProviderMock ¶
type ProviderMock struct {
// CompletionFunc mocks the Completion method.
CompletionFunc func(ctx context.Context, params llm.CompletionParams) (*llm.CompletionResult, error)
// contains filtered or unexported fields
}
ProviderMock is a mock implementation of llm.Provider.
func TestSomethingThatUsesProvider(t *testing.T) {
// make and configure a mocked llm.Provider
mockedProvider := &ProviderMock{
CompletionFunc: func(ctx context.Context, params llm.CompletionParams) (*llm.CompletionResult, error) {
panic("mock out the Completion method")
},
}
// use mockedProvider in code that requires llm.Provider
// and then make assertions.
}
func (*ProviderMock) Completion ¶
func (mock *ProviderMock) Completion(ctx context.Context, params llm.CompletionParams) (*llm.CompletionResult, error)
Completion calls CompletionFunc.
func (*ProviderMock) CompletionCalls ¶
func (mock *ProviderMock) CompletionCalls() []struct { Ctx context.Context Params llm.CompletionParams }
CompletionCalls gets all the calls that were made to Completion. Check the length with:
len(mockedProvider.CompletionCalls())
Click to show internal directories.
Click to hide internal directories.