testutil

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package testutil provides test helpers for Kiseki.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestDB

func NewTestDB() *sql.DB

NewTestDB creates an in-memory SQLite database fully initialized via db.InitDB. Uses cache=shared so all connections in the pool share the same in-memory DB. This is critical for MultiLayerSearch tests which use goroutines (each goroutine may get a different connection from the pool).

Types

type MockEmbedder

type MockEmbedder struct {
	// Dimension is the vector size. Defaults to db.EmbedDimension if 0.
	Dimension int
	// CallCount tracks how many times Embed was called.
	CallCount int
	// contains filtered or unexported fields
}

MockEmbedder implements ollama.Embedder with deterministic vectors. It generates consistent embeddings based on text content using FNV hashing, producing vectors that have meaningful cosine similarity (similar words → closer vectors).

func (*MockEmbedder) Embed

func (m *MockEmbedder) Embed(_ context.Context, text string) ([]float32, error)

Embed produces a deterministic float32 vector from the input text. The same text always produces the same vector. Different texts produce different vectors with reasonable cosine distance.

Jump to

Keyboard shortcuts

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