mock

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LLMClientMock

type LLMClientMock struct {
	// GenerateEmbeddingFunc mocks the GenerateEmbedding method.
	GenerateEmbeddingFunc func(ctx context.Context, dimension int, input []string) ([][]float64, error)

	// NewSessionFunc mocks the NewSession method.
	NewSessionFunc func(ctx context.Context, options ...gollem.SessionOption) (gollem.Session, error)
	// contains filtered or unexported fields
}

LLMClientMock is a mock implementation of gollem.LLMClient.

func TestSomethingThatUsesLLMClient(t *testing.T) {

	// make and configure a mocked gollem.LLMClient
	mockedLLMClient := &LLMClientMock{
		GenerateEmbeddingFunc: func(ctx context.Context, dimension int, input []string) ([][]float64, error) {
			panic("mock out the GenerateEmbedding method")
		},
		NewSessionFunc: func(ctx context.Context, options ...gollem.SessionOption) (gollem.Session, error) {
			panic("mock out the NewSession method")
		},
	}

	// use mockedLLMClient in code that requires gollem.LLMClient
	// and then make assertions.

}

func (*LLMClientMock) GenerateEmbedding

func (mock *LLMClientMock) GenerateEmbedding(ctx context.Context, dimension int, input []string) ([][]float64, error)

GenerateEmbedding calls GenerateEmbeddingFunc.

func (*LLMClientMock) GenerateEmbeddingCalls

func (mock *LLMClientMock) GenerateEmbeddingCalls() []struct {
	Ctx       context.Context
	Dimension int
	Input     []string
}

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

len(mockedLLMClient.GenerateEmbeddingCalls())

func (*LLMClientMock) NewSession

func (mock *LLMClientMock) NewSession(ctx context.Context, options ...gollem.SessionOption) (gollem.Session, error)

NewSession calls NewSessionFunc.

func (*LLMClientMock) NewSessionCalls

func (mock *LLMClientMock) NewSessionCalls() []struct {
	Ctx     context.Context
	Options []gollem.SessionOption
}

NewSessionCalls gets all the calls that were made to NewSession. Check the length with:

len(mockedLLMClient.NewSessionCalls())

type SessionMock

type SessionMock struct {
	// AppendHistoryFunc mocks the AppendHistory method.
	AppendHistoryFunc func(history *gollem.History) error

	// CountTokenFunc mocks the CountToken method.
	CountTokenFunc func(ctx context.Context, input ...gollem.Input) (int, error)

	// GenerateFunc mocks the Generate method.
	GenerateFunc func(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (*gollem.Response, error)

	// StreamFunc mocks the Stream method.
	StreamFunc func(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (<-chan *gollem.Response, error)

	// HistoryFunc mocks the History method.
	HistoryFunc func() (*gollem.History, error)
	// contains filtered or unexported fields
}

SessionMock is a mock implementation of gollem.Session.

func TestSomethingThatUsesSession(t *testing.T) {

	// make and configure a mocked gollem.Session
	mockedSession := &SessionMock{
		AppendHistoryFunc: func(history *gollem.History) error {
			panic("mock out the AppendHistory method")
		},
		CountTokenFunc: func(ctx context.Context, input ...gollem.Input) (int, error) {
			panic("mock out the CountToken method")
		},
		GenerateFunc: func(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (*gollem.Response, error) {
			panic("mock out the Generate method")
		},
		StreamFunc: func(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (<-chan *gollem.Response, error) {
			panic("mock out the Stream method")
		},
		HistoryFunc: func() (*gollem.History, error) {
			panic("mock out the History method")
		},
	}

	// use mockedSession in code that requires gollem.Session
	// and then make assertions.

}

func (*SessionMock) AppendHistory

func (mock *SessionMock) AppendHistory(history *gollem.History) error

AppendHistory calls AppendHistoryFunc.

func (*SessionMock) AppendHistoryCalls

func (mock *SessionMock) AppendHistoryCalls() []struct {
	History *gollem.History
}

AppendHistoryCalls gets all the calls that were made to AppendHistory. Check the length with:

len(mockedSession.AppendHistoryCalls())

func (*SessionMock) CountToken

func (mock *SessionMock) CountToken(ctx context.Context, input ...gollem.Input) (int, error)

CountToken calls CountTokenFunc.

func (*SessionMock) CountTokenCalls

func (mock *SessionMock) CountTokenCalls() []struct {
	Ctx   context.Context
	Input []gollem.Input
}

CountTokenCalls gets all the calls that were made to CountToken. Check the length with:

len(mockedSession.CountTokenCalls())

func (*SessionMock) Generate

func (mock *SessionMock) Generate(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (*gollem.Response, error)

Generate calls GenerateFunc.

func (*SessionMock) GenerateCalls

func (mock *SessionMock) GenerateCalls() []struct {
	Ctx   context.Context
	Input []gollem.Input
	Opts  []gollem.GenerateOption
}

GenerateCalls gets all the calls that were made to Generate. Check the length with:

len(mockedSession.GenerateCalls())

func (*SessionMock) GenerateContent deprecated

func (mock *SessionMock) GenerateContent(ctx context.Context, input ...gollem.Input) (*gollem.Response, error)

Deprecated: GenerateContent delegates to Generate for backward compatibility.

func (*SessionMock) GenerateStream deprecated

func (mock *SessionMock) GenerateStream(ctx context.Context, input ...gollem.Input) (<-chan *gollem.Response, error)

Deprecated: GenerateStream delegates to Stream for backward compatibility.

func (*SessionMock) History

func (mock *SessionMock) History() (*gollem.History, error)

History calls HistoryFunc.

func (*SessionMock) HistoryCalls

func (mock *SessionMock) HistoryCalls() []struct {
}

HistoryCalls gets all the calls that were made to History. Check the length with:

len(mockedSession.HistoryCalls())

func (*SessionMock) Stream

func (mock *SessionMock) Stream(ctx context.Context, input []gollem.Input, opts ...gollem.GenerateOption) (<-chan *gollem.Response, error)

Stream calls StreamFunc.

func (*SessionMock) StreamCalls

func (mock *SessionMock) StreamCalls() []struct {
	Ctx   context.Context
	Input []gollem.Input
	Opts  []gollem.GenerateOption
}

StreamCalls gets all the calls that were made to Stream. Check the length with:

len(mockedSession.StreamCalls())

type StrategyMock

type StrategyMock struct {
	// HandleFunc mocks the Handle method.
	HandleFunc func(ctx context.Context, state *gollem.StrategyState) ([]gollem.Input, *gollem.ExecuteResponse, error)

	// InitFunc mocks the Init method.
	InitFunc func(ctx context.Context, inputs []gollem.Input) error

	// ToolsFunc mocks the Tools method.
	ToolsFunc func(ctx context.Context) ([]gollem.Tool, error)
	// contains filtered or unexported fields
}

StrategyMock is a mock implementation of gollem.Strategy.

func TestSomethingThatUsesStrategy(t *testing.T) {

	// make and configure a mocked gollem.Strategy
	mockedStrategy := &StrategyMock{
		HandleFunc: func(ctx context.Context, state *gollem.StrategyState) ([]gollem.Input, *gollem.ExecuteResponse, error) {
			panic("mock out the Handle method")
		},
		InitFunc: func(ctx context.Context, inputs []gollem.Input) error {
			panic("mock out the Init method")
		},
		ToolsFunc: func(ctx context.Context) ([]gollem.Tool, error) {
			panic("mock out the Tools method")
		},
	}

	// use mockedStrategy in code that requires gollem.Strategy
	// and then make assertions.

}

func (*StrategyMock) Handle

Handle calls HandleFunc.

func (*StrategyMock) HandleCalls

func (mock *StrategyMock) HandleCalls() []struct {
	Ctx   context.Context
	State *gollem.StrategyState
}

HandleCalls gets all the calls that were made to Handle. Check the length with:

len(mockedStrategy.HandleCalls())

func (*StrategyMock) Init

func (mock *StrategyMock) Init(ctx context.Context, inputs []gollem.Input) error

Init calls InitFunc.

func (*StrategyMock) InitCalls

func (mock *StrategyMock) InitCalls() []struct {
	Ctx    context.Context
	Inputs []gollem.Input
}

InitCalls gets all the calls that were made to Init. Check the length with:

len(mockedStrategy.InitCalls())

func (*StrategyMock) Tools

func (mock *StrategyMock) Tools(ctx context.Context) ([]gollem.Tool, error)

Tools calls ToolsFunc.

func (*StrategyMock) ToolsCalls

func (mock *StrategyMock) ToolsCalls() []struct {
	Ctx context.Context
}

ToolsCalls gets all the calls that were made to Tools. Check the length with:

len(mockedStrategy.ToolsCalls())

type ToolMock

type ToolMock struct {
	// RunFunc mocks the Run method.
	RunFunc func(ctx context.Context, args map[string]any) (map[string]any, error)

	// SpecFunc mocks the Spec method.
	SpecFunc func() gollem.ToolSpec
	// contains filtered or unexported fields
}

ToolMock is a mock implementation of gollem.Tool.

func TestSomethingThatUsesTool(t *testing.T) {

	// make and configure a mocked gollem.Tool
	mockedTool := &ToolMock{
		RunFunc: func(ctx context.Context, args map[string]any) (map[string]any, error) {
			panic("mock out the Run method")
		},
		SpecFunc: func() gollem.ToolSpec {
			panic("mock out the Spec method")
		},
	}

	// use mockedTool in code that requires gollem.Tool
	// and then make assertions.

}

func (*ToolMock) Run

func (mock *ToolMock) Run(ctx context.Context, args map[string]any) (map[string]any, error)

Run calls RunFunc.

func (*ToolMock) RunCalls

func (mock *ToolMock) RunCalls() []struct {
	Ctx  context.Context
	Args map[string]any
}

RunCalls gets all the calls that were made to Run. Check the length with:

len(mockedTool.RunCalls())

func (*ToolMock) Spec

func (mock *ToolMock) Spec() gollem.ToolSpec

Spec calls SpecFunc.

func (*ToolMock) SpecCalls

func (mock *ToolMock) SpecCalls() []struct {
}

SpecCalls gets all the calls that were made to Spec. Check the length with:

len(mockedTool.SpecCalls())

Jump to

Keyboard shortcuts

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