Documentation
¶
Overview ¶
Package testutil provides shared, scriptable test doubles for the SDK's own tests.
Before this package there were a dozen separate hand-rolled mock LLMs across pkg/agent, pkg/memory, pkg/llm and pkg/microservice, each implementing the same six interfaces.LLM methods slightly differently and none of them safe for concurrent use. Every new test either grew a thirteenth or borrowed one from an unrelated file.
All doubles here are safe to call from multiple goroutines, so a test that reports a race is reporting a race in the code under test.
It lives under internal/ deliberately: these are conveniences for this module's tests, not API this module supports for downstream users.
Index ¶
- Variables
- type FakeConversationMemory
- type FakeImageEditSession
- func (s *FakeImageEditSession) Close() error
- func (s *FakeImageEditSession) Closed() bool
- func (s *FakeImageEditSession) GetHistory() []interfaces.ImageEditTurn
- func (s *FakeImageEditSession) LastOptions() *interfaces.ImageEditOptions
- func (s *FakeImageEditSession) Prompts() []string
- func (s *FakeImageEditSession) SendMessage(_ context.Context, msg string, opts *interfaces.ImageEditOptions) (*interfaces.ImageEditResponse, error)
- func (s *FakeImageEditSession) SendMessageWithImage(context.Context, string, *interfaces.ImageData, *interfaces.ImageEditOptions) (*interfaces.ImageEditResponse, error)
- func (s *FakeImageEditSession) SetErr(err error)
- func (s *FakeImageEditSession) SetHistory(history []interfaces.ImageEditTurn)
- type FakeImageEditor
- func (e *FakeImageEditor) CreateImageEditSession(_ context.Context, opts *interfaces.ImageEditSessionOptions) (interfaces.ImageEditSession, error)
- func (e *FakeImageEditor) LastOptions() *interfaces.ImageEditSessionOptions
- func (e *FakeImageEditor) Sessions() []*FakeImageEditSession
- func (e *FakeImageEditor) SupportsMultiTurnImageEditing() bool
- type FakeImageStorage
- func (f *FakeImageStorage) Delete(context.Context, string) error
- func (f *FakeImageStorage) Get(context.Context, string) ([]byte, error)
- func (f *FakeImageStorage) Metadata() []storage.StorageMetadata
- func (f *FakeImageStorage) Name() string
- func (f *FakeImageStorage) Store(_ context.Context, img *interfaces.GeneratedImage, ...) (string, error)
- type FakeLLM
- func (f *FakeLLM) Calls() int
- func (f *FakeLLM) Generate(ctx context.Context, prompt string, _ ...interfaces.GenerateOption) (string, error)
- func (f *FakeLLM) GenerateDetailed(ctx context.Context, prompt string, _ ...interfaces.GenerateOption) (*interfaces.LLMResponse, error)
- func (f *FakeLLM) GenerateStream(ctx context.Context, prompt string, _ ...interfaces.GenerateOption) (<-chan interfaces.StreamEvent, error)
- func (f *FakeLLM) GenerateWithTools(ctx context.Context, prompt string, toolSet []interfaces.Tool, ...) (string, error)
- func (f *FakeLLM) GenerateWithToolsDetailed(ctx context.Context, prompt string, toolSet []interfaces.Tool, ...) (*interfaces.LLMResponse, error)
- func (f *FakeLLM) GenerateWithToolsStream(ctx context.Context, prompt string, toolSet []interfaces.Tool, ...) (<-chan interfaces.StreamEvent, error)
- func (f *FakeLLM) Name() string
- func (f *FakeLLM) Prompts() []string
- func (f *FakeLLM) SupportsStreaming() bool
- func (f *FakeLLM) ToolNamesAt(i int) []string
- type FakeMemory
- type FakeSQL
- type FakeSQLCall
- type FakeSQLResponse
- type FakeSpan
- func (s *FakeSpan) AddEvent(name string, _ map[string]interface{})
- func (s *FakeSpan) Attribute(key string) (interface{}, bool)
- func (s *FakeSpan) End()
- func (s *FakeSpan) Ended() bool
- func (s *FakeSpan) Errors() []error
- func (s *FakeSpan) RecordError(err error)
- func (s *FakeSpan) SetAttribute(key string, value interface{})
- type FakeTool
- func (f *FakeTool) CallCount() int
- func (f *FakeTool) Calls() []string
- func (f *FakeTool) Description() string
- func (f *FakeTool) DisplayName() string
- func (f *FakeTool) Execute(ctx context.Context, args string) (string, error)
- func (f *FakeTool) Internal() bool
- func (f *FakeTool) Name() string
- func (f *FakeTool) Parameters() map[string]interfaces.ParameterSpec
- func (f *FakeTool) Run(ctx context.Context, input string) (string, error)
- type FakeTracer
- type FakeVectorStore
- func (f *FakeVectorStore) CreateTenant(context.Context, string) error
- func (f *FakeVectorStore) Delete(context.Context, []string, ...interfaces.DeleteOption) error
- func (f *FakeVectorStore) DeleteTenant(context.Context, string) error
- func (f *FakeVectorStore) Get(_ context.Context, id string, _ ...interfaces.StoreOption) (*interfaces.Document, error)
- func (f *FakeVectorStore) GlobalDelete(context.Context, []string, ...interfaces.DeleteOption) error
- func (f *FakeVectorStore) GlobalSearch(ctx context.Context, query string, limit int, opts ...interfaces.SearchOption) ([]interfaces.SearchResult, error)
- func (f *FakeVectorStore) GlobalSearchByVector(ctx context.Context, vector []float32, limit int, ...) ([]interfaces.SearchResult, error)
- func (f *FakeVectorStore) GlobalStore(ctx context.Context, documents []interfaces.Document, ...) error
- func (f *FakeVectorStore) ListTenants(context.Context) ([]string, error)
- func (f *FakeVectorStore) Search(_ context.Context, query string, _ int, _ ...interfaces.SearchOption) ([]interfaces.SearchResult, error)
- func (f *FakeVectorStore) SearchByVector(_ context.Context, _ []float32, _ int, _ ...interfaces.SearchOption) ([]interfaces.SearchResult, error)
- func (f *FakeVectorStore) Searches() []string
- func (f *FakeVectorStore) Store(_ context.Context, documents []interfaces.Document, ...) error
- func (f *FakeVectorStore) Stored() []interfaces.Document
- type FakeWeaviate
- func (fw *FakeWeaviate) GraphQLQueries() []string
- func (fw *FakeWeaviate) Host() string
- func (fw *FakeWeaviate) RequestsTo(method, path string) []WeaviateRequest
- func (fw *FakeWeaviate) Reset()
- func (fw *FakeWeaviate) SetGraphQL(h func(query string) WeaviateReply)
- func (fw *FakeWeaviate) SetHandle(h func(WeaviateRequest) (WeaviateReply, bool))
- type WeaviateReply
- type WeaviateRequest
Constants ¶
This section is empty.
Variables ¶
var ( SamplePNG = []byte("\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01") SampleJPEG = []byte("\xff\xd8\xff\xe0\x00\x10JFIF\x00") SampleGIF = []byte("GIF89a\x01\x00\x01\x00") SampleWebP = []byte("RIFF\x24\x00\x00\x00WEBPVP8 ") SamplePDF = []byte("%PDF-1.4\n%sample\n") SampleBMP = []byte("BM\x36\x00\x00\x00\x00\x00") )
Sample file headers that http.DetectContentType recognizes. They are not complete images or documents: they exercise type detection only, so use them where the data is checked by its type and not decoded.
Functions ¶
This section is empty.
Types ¶
type FakeConversationMemory ¶
type FakeConversationMemory struct {
FakeMemory
// Conversations is returned by GetAllConversations.
Conversations []string
}
FakeConversationMemory is a FakeMemory that also implements interfaces.ConversationMemory, for testing capability discovery through decorators.
func (*FakeConversationMemory) GetAllConversations ¶
func (f *FakeConversationMemory) GetAllConversations(context.Context) ([]string, error)
GetAllConversations implements interfaces.ConversationMemory.
func (*FakeConversationMemory) GetConversationMessages ¶
func (f *FakeConversationMemory) GetConversationMessages(ctx context.Context, _ string) ([]interfaces.Message, error)
GetConversationMessages implements interfaces.ConversationMemory.
func (*FakeConversationMemory) GetMemoryStatistics ¶
GetMemoryStatistics implements interfaces.ConversationMemory.
type FakeImageEditSession ¶ added in v0.2.85
type FakeImageEditSession struct {
// contains filtered or unexported fields
}
FakeImageEditSession is a scriptable interfaces.ImageEditSession that answers every SendMessage with a fixed response and error and records what it was sent. Build one with NewFakeImageEditSession.
func NewFakeImageEditSession ¶ added in v0.2.85
func NewFakeImageEditSession(resp *interfaces.ImageEditResponse, err error) *FakeImageEditSession
NewFakeImageEditSession returns a session that answers with resp and err. A nil resp is replaced by an empty response.
func (*FakeImageEditSession) Close ¶ added in v0.2.85
func (s *FakeImageEditSession) Close() error
Close implements interfaces.ImageEditSession.
func (*FakeImageEditSession) Closed ¶ added in v0.2.85
func (s *FakeImageEditSession) Closed() bool
Closed reports whether Close was called.
func (*FakeImageEditSession) GetHistory ¶ added in v0.2.85
func (s *FakeImageEditSession) GetHistory() []interfaces.ImageEditTurn
GetHistory implements interfaces.ImageEditSession.
func (*FakeImageEditSession) LastOptions ¶ added in v0.2.85
func (s *FakeImageEditSession) LastOptions() *interfaces.ImageEditOptions
LastOptions returns the options of the last SendMessage call.
func (*FakeImageEditSession) Prompts ¶ added in v0.2.85
func (s *FakeImageEditSession) Prompts() []string
Prompts returns every message sent, in order.
func (*FakeImageEditSession) SendMessage ¶ added in v0.2.85
func (s *FakeImageEditSession) SendMessage(_ context.Context, msg string, opts *interfaces.ImageEditOptions) (*interfaces.ImageEditResponse, error)
SendMessage implements interfaces.ImageEditSession.
func (*FakeImageEditSession) SendMessageWithImage ¶ added in v0.2.85
func (s *FakeImageEditSession) SendMessageWithImage(context.Context, string, *interfaces.ImageData, *interfaces.ImageEditOptions) (*interfaces.ImageEditResponse, error)
SendMessageWithImage implements interfaces.ImageEditSession. It is not scripted and always fails.
func (*FakeImageEditSession) SetErr ¶ added in v0.2.85
func (s *FakeImageEditSession) SetErr(err error)
SetErr changes the error returned by later SendMessage calls.
func (*FakeImageEditSession) SetHistory ¶ added in v0.2.85
func (s *FakeImageEditSession) SetHistory(history []interfaces.ImageEditTurn)
SetHistory sets the history returned by GetHistory.
type FakeImageEditor ¶ added in v0.2.85
type FakeImageEditor struct {
NewSession func() *FakeImageEditSession
Err error
Unsupported bool
// contains filtered or unexported fields
}
FakeImageEditor is a scriptable interfaces.MultiTurnImageEditor.
Each CreateImageEditSession call builds a session with NewSession, or an empty-response session when NewSession is nil, unless Err is set.
func (*FakeImageEditor) CreateImageEditSession ¶ added in v0.2.85
func (e *FakeImageEditor) CreateImageEditSession(_ context.Context, opts *interfaces.ImageEditSessionOptions) (interfaces.ImageEditSession, error)
CreateImageEditSession implements interfaces.MultiTurnImageEditor.
func (*FakeImageEditor) LastOptions ¶ added in v0.2.85
func (e *FakeImageEditor) LastOptions() *interfaces.ImageEditSessionOptions
LastOptions returns the options of the last CreateImageEditSession call.
func (*FakeImageEditor) Sessions ¶ added in v0.2.85
func (e *FakeImageEditor) Sessions() []*FakeImageEditSession
Sessions returns every session handed out, in order.
func (*FakeImageEditor) SupportsMultiTurnImageEditing ¶ added in v0.2.85
func (e *FakeImageEditor) SupportsMultiTurnImageEditing() bool
SupportsMultiTurnImageEditing implements interfaces.MultiTurnImageEditor.
type FakeImageStorage ¶ added in v0.2.85
type FakeImageStorage struct {
Err error
// StorageName is returned by Name; it defaults to "fake".
StorageName string
// contains filtered or unexported fields
}
FakeImageStorage is a storage.ImageStorage that returns "https://cdn.test/<mime type>" for every stored image, or Err when set.
func (*FakeImageStorage) Delete ¶ added in v0.2.85
func (f *FakeImageStorage) Delete(context.Context, string) error
Delete implements storage.ImageStorage.
func (*FakeImageStorage) Metadata ¶ added in v0.2.85
func (f *FakeImageStorage) Metadata() []storage.StorageMetadata
Metadata returns the metadata of every stored image, in order.
func (*FakeImageStorage) Name ¶ added in v0.2.85
func (f *FakeImageStorage) Name() string
Name implements storage.ImageStorage.
func (*FakeImageStorage) Store ¶ added in v0.2.85
func (f *FakeImageStorage) Store(_ context.Context, img *interfaces.GeneratedImage, meta storage.StorageMetadata) (string, error)
Store implements storage.ImageStorage.
type FakeLLM ¶
type FakeLLM struct {
// ProviderName is returned by Name. Defaults to "fake".
ProviderName string
// ModelName is reported on LLMResponse.Model. Defaults to "fake-model".
ModelName string
// DefaultResponse is returned once Responses is exhausted.
DefaultResponse string
// Responses is consumed in order, one per Generate* call.
Responses []string
// Err, when set, is returned by every Generate* call.
Err error
// Usage, when set, is reported on every detailed response.
Usage *interfaces.TokenUsage
// GenerateFunc, when set, overrides all of the above.
GenerateFunc func(ctx context.Context, prompt string, tools []interfaces.Tool) (string, error)
// InvokeTools, when true, calls Execute on every supplied tool before
// answering. Useful for exercising tool plumbing without a real model.
InvokeTools bool
// Streaming reports whether SupportsStreaming returns true. Defaults false.
Streaming bool
// contains filtered or unexported fields
}
FakeLLM is a scriptable interfaces.LLM and interfaces.StreamingLLM.
The zero value is usable: it answers every prompt with DefaultResponse. Queue specific answers with Responses, or take full control with GenerateFunc.
func NewFakeLLM ¶
func NewFakeLLM() *FakeLLM
NewFakeLLM returns a FakeLLM that answers every prompt with "ok". It exists so migrated call sites read as intent rather than struct literals.
func (*FakeLLM) Generate ¶
func (f *FakeLLM) Generate(ctx context.Context, prompt string, _ ...interfaces.GenerateOption) (string, error)
Generate implements interfaces.LLM.
func (*FakeLLM) GenerateDetailed ¶
func (f *FakeLLM) GenerateDetailed(ctx context.Context, prompt string, _ ...interfaces.GenerateOption) (*interfaces.LLMResponse, error)
GenerateDetailed implements interfaces.LLM.
func (*FakeLLM) GenerateStream ¶
func (f *FakeLLM) GenerateStream(ctx context.Context, prompt string, _ ...interfaces.GenerateOption) (<-chan interfaces.StreamEvent, error)
GenerateStream implements interfaces.StreamingLLM, emitting the scripted answer as one content event followed by completion.
func (*FakeLLM) GenerateWithTools ¶
func (f *FakeLLM) GenerateWithTools(ctx context.Context, prompt string, toolSet []interfaces.Tool, _ ...interfaces.GenerateOption) (string, error)
GenerateWithTools implements interfaces.LLM.
func (*FakeLLM) GenerateWithToolsDetailed ¶
func (f *FakeLLM) GenerateWithToolsDetailed(ctx context.Context, prompt string, toolSet []interfaces.Tool, _ ...interfaces.GenerateOption) (*interfaces.LLMResponse, error)
GenerateWithToolsDetailed implements interfaces.LLM.
func (*FakeLLM) GenerateWithToolsStream ¶
func (f *FakeLLM) GenerateWithToolsStream(ctx context.Context, prompt string, toolSet []interfaces.Tool, _ ...interfaces.GenerateOption) (<-chan interfaces.StreamEvent, error)
GenerateWithToolsStream implements interfaces.StreamingLLM.
func (*FakeLLM) SupportsStreaming ¶
SupportsStreaming implements interfaces.LLM.
func (*FakeLLM) ToolNamesAt ¶
ToolNamesAt returns the tool names supplied to the i'th call.
type FakeMemory ¶
type FakeMemory struct {
// Conversational makes the fake report conversation-level capability.
Conversational bool
// contains filtered or unexported fields
}
FakeMemory is an in-process interfaces.Memory keyed by a single scope, for tests that do not care about org or conversation scoping.
Set Conversational to also satisfy interfaces.ConversationMemory.
func (*FakeMemory) AddMessage ¶
func (f *FakeMemory) AddMessage(_ context.Context, message interfaces.Message) error
AddMessage implements interfaces.Memory.
func (*FakeMemory) Clear ¶
func (f *FakeMemory) Clear(_ context.Context) error
Clear implements interfaces.Memory.
func (*FakeMemory) GetMessages ¶
func (f *FakeMemory) GetMessages(_ context.Context, _ ...interfaces.GetMessagesOption) ([]interfaces.Message, error)
GetMessages implements interfaces.Memory.
type FakeSQL ¶ added in v0.2.85
type FakeSQL struct {
// Respond answers every query and exec. Nil answers with an empty response.
Respond func(query string) FakeSQLResponse
PingErr error
BeginErr error
CommitErr error
RollbackErr error
// contains filtered or unexported fields
}
FakeSQL is a minimal database/sql driver that records statements and replies with scripted responses, so tests can check the SQL a client builds without a real database server.
Set the fields before calling Open; they are read without locking.
func (*FakeSQL) Calls ¶ added in v0.2.85
func (f *FakeSQL) Calls() []FakeSQLCall
Calls returns every statement received, in order.
func (*FakeSQL) Committed ¶ added in v0.2.85
Committed returns how many transactions reached the driver's Commit.
func (*FakeSQL) LastCall ¶ added in v0.2.85
func (f *FakeSQL) LastCall() FakeSQLCall
LastCall returns the most recent statement, or the zero value if none.
func (*FakeSQL) RolledBack ¶ added in v0.2.85
RolledBack returns how many transactions reached the driver's Rollback.
type FakeSQLCall ¶ added in v0.2.85
FakeSQLCall records one statement sent to FakeSQL.
type FakeSQLResponse ¶ added in v0.2.85
type FakeSQLResponse struct {
Columns []string
Rows [][]driver.Value
RowsAffected int64
// Err is returned by the query or exec call itself.
Err error
// AffectedErr is returned by Result.RowsAffected.
AffectedErr error
// IterErr is returned by Rows.Next after the last row.
IterErr error
}
FakeSQLResponse is what FakeSQL returns for one statement.
type FakeSpan ¶
type FakeSpan struct {
// contains filtered or unexported fields
}
FakeSpan is an inert interfaces.Span that records what it was told.
func (*FakeSpan) RecordError ¶
RecordError implements interfaces.Span.
func (*FakeSpan) SetAttribute ¶
SetAttribute implements interfaces.Span.
type FakeTool ¶
type FakeTool struct {
// ToolName is returned by Name. Defaults to "fake_tool".
ToolName string
// Desc is returned by Description.
Desc string
// Result is returned by Run and Execute when ExecuteFunc is nil.
Result string
// Err, when set, is returned by Run and Execute.
Err error
// Params is returned by Parameters. Defaults to an empty map.
Params map[string]interfaces.ParameterSpec
// ExecuteFunc, when set, overrides Result and Err.
ExecuteFunc func(ctx context.Context, args string) (string, error)
// Display, when non-empty, is returned by DisplayName.
Display string
// IsInternal is returned by Internal.
IsInternal bool
// contains filtered or unexported fields
}
FakeTool is a scriptable interfaces.Tool that records its invocations.
func (*FakeTool) Description ¶
Description implements interfaces.Tool.
func (*FakeTool) DisplayName ¶
DisplayName implements interfaces.ToolWithDisplayName.
func (*FakeTool) Parameters ¶
func (f *FakeTool) Parameters() map[string]interfaces.ParameterSpec
Parameters implements interfaces.Tool.
type FakeTracer ¶
type FakeTracer struct {
// contains filtered or unexported fields
}
FakeTracer is an inert interfaces.Tracer that hands out FakeSpans.
func (*FakeTracer) SpanNames ¶
func (t *FakeTracer) SpanNames() []string
SpanNames returns the names of every span started, in order.
func (*FakeTracer) Spans ¶
func (t *FakeTracer) Spans() []*FakeSpan
Spans returns every span handed out, in order.
func (*FakeTracer) StartSpan ¶
func (t *FakeTracer) StartSpan(ctx context.Context, name string) (context.Context, interfaces.Span)
StartSpan implements interfaces.Tracer.
func (*FakeTracer) StartTraceSession ¶
func (t *FakeTracer) StartTraceSession(ctx context.Context, name string) (context.Context, interfaces.Span)
StartTraceSession implements interfaces.Tracer.
type FakeVectorStore ¶
type FakeVectorStore struct {
// Results is returned by Search and SearchByVector.
Results []interfaces.SearchResult
// SearchErr, when set, is returned by every search.
SearchErr error
// StoreErr, when set, is returned by every store.
StoreErr error
// contains filtered or unexported fields
}
FakeVectorStore is an interfaces.VectorStore that records what it was asked to store and search, and returns canned results.
interfaces.VectorStore is a twelve-method interface, so hand-rolling one per test is exactly the duplication this package exists to prevent.
func (*FakeVectorStore) CreateTenant ¶
func (f *FakeVectorStore) CreateTenant(context.Context, string) error
CreateTenant implements interfaces.VectorStore.
func (*FakeVectorStore) Delete ¶
func (f *FakeVectorStore) Delete(context.Context, []string, ...interfaces.DeleteOption) error
Delete implements interfaces.VectorStore.
func (*FakeVectorStore) DeleteTenant ¶
func (f *FakeVectorStore) DeleteTenant(context.Context, string) error
DeleteTenant implements interfaces.VectorStore.
func (*FakeVectorStore) Get ¶
func (f *FakeVectorStore) Get(_ context.Context, id string, _ ...interfaces.StoreOption) (*interfaces.Document, error)
Get implements interfaces.VectorStore.
func (*FakeVectorStore) GlobalDelete ¶
func (f *FakeVectorStore) GlobalDelete(context.Context, []string, ...interfaces.DeleteOption) error
GlobalDelete implements interfaces.VectorStore.
func (*FakeVectorStore) GlobalSearch ¶
func (f *FakeVectorStore) GlobalSearch(ctx context.Context, query string, limit int, opts ...interfaces.SearchOption) ([]interfaces.SearchResult, error)
GlobalSearch implements interfaces.VectorStore.
func (*FakeVectorStore) GlobalSearchByVector ¶
func (f *FakeVectorStore) GlobalSearchByVector(ctx context.Context, vector []float32, limit int, opts ...interfaces.SearchOption) ([]interfaces.SearchResult, error)
GlobalSearchByVector implements interfaces.VectorStore.
func (*FakeVectorStore) GlobalStore ¶
func (f *FakeVectorStore) GlobalStore(ctx context.Context, documents []interfaces.Document, opts ...interfaces.StoreOption) error
GlobalStore implements interfaces.VectorStore.
func (*FakeVectorStore) ListTenants ¶
func (f *FakeVectorStore) ListTenants(context.Context) ([]string, error)
ListTenants implements interfaces.VectorStore.
func (*FakeVectorStore) Search ¶
func (f *FakeVectorStore) Search(_ context.Context, query string, _ int, _ ...interfaces.SearchOption) ([]interfaces.SearchResult, error)
Search implements interfaces.VectorStore.
func (*FakeVectorStore) SearchByVector ¶
func (f *FakeVectorStore) SearchByVector(_ context.Context, _ []float32, _ int, _ ...interfaces.SearchOption) ([]interfaces.SearchResult, error)
SearchByVector implements interfaces.VectorStore.
func (*FakeVectorStore) Searches ¶
func (f *FakeVectorStore) Searches() []string
Searches returns every query passed to Search, in order.
func (*FakeVectorStore) Store ¶
func (f *FakeVectorStore) Store(_ context.Context, documents []interfaces.Document, _ ...interfaces.StoreOption) error
Store implements interfaces.VectorStore.
func (*FakeVectorStore) Stored ¶
func (f *FakeVectorStore) Stored() []interfaces.Document
Stored returns every document handed to Store, in order.
type FakeWeaviate ¶ added in v0.2.85
type FakeWeaviate struct {
// contains filtered or unexported fields
}
FakeWeaviate is an httptest server that speaks enough of the Weaviate REST and GraphQL API for a client to run against it. It records every request. Tests override replies with SetHandle and SetGraphQL.
func NewFakeWeaviate ¶ added in v0.2.85
func NewFakeWeaviate(t *testing.T) *FakeWeaviate
NewFakeWeaviate starts a FakeWeaviate that is closed when the test ends.
func (*FakeWeaviate) GraphQLQueries ¶ added in v0.2.85
func (fw *FakeWeaviate) GraphQLQueries() []string
GraphQLQueries returns the GraphQL query texts received so far, in order.
func (*FakeWeaviate) Host ¶ added in v0.2.85
func (fw *FakeWeaviate) Host() string
Host returns the server's host:port, as the Weaviate client config wants it.
func (*FakeWeaviate) RequestsTo ¶ added in v0.2.85
func (fw *FakeWeaviate) RequestsTo(method, path string) []WeaviateRequest
RequestsTo returns the recorded requests that match method and path.
func (*FakeWeaviate) Reset ¶ added in v0.2.85
func (fw *FakeWeaviate) Reset()
Reset forgets the recorded requests.
func (*FakeWeaviate) SetGraphQL ¶ added in v0.2.85
func (fw *FakeWeaviate) SetGraphQL(h func(query string) WeaviateReply)
SetGraphQL answers GraphQL queries that the handle does not take. The default returns no data.
func (*FakeWeaviate) SetHandle ¶ added in v0.2.85
func (fw *FakeWeaviate) SetHandle(h func(WeaviateRequest) (WeaviateReply, bool))
SetHandle installs a handler that answers before the defaults. It returns false to fall through to the defaults. Nil removes it.
type WeaviateReply ¶ added in v0.2.85
WeaviateReply is the status and JSON body FakeWeaviate sends back.