mock

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package mock provides a mock implementation of vectorstore.Store for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {

	// Hooks for testing behavior
	EnsureCollectionFunc func(ctx context.Context, name string, dim int) error
	UpsertFunc           func(ctx context.Context, collection string, points []vectorstore.Point) error
	SearchFunc           func(ctx context.Context, collection string, vector []float32, topK int) ([]vectorstore.Result, error)
	// contains filtered or unexported fields
}

Store is an in-memory mock implementation of vectorstore.Store. Useful for testing without a real vector database.

func New

func New() *Store

New creates a new mock store.

func (*Store) Close

func (s *Store) Close() error

Close marks the store as closed.

func (*Store) Count

func (s *Store) Count(ctx context.Context, collectionName string) (int64, error)

Count returns the number of points in a collection.

func (*Store) DeleteCollection

func (s *Store) DeleteCollection(ctx context.Context, name string) error

DeleteCollection removes a collection and all its data.

func (*Store) EnsureCollection

func (s *Store) EnsureCollection(ctx context.Context, name string, dim int) error

EnsureCollection creates a collection if it doesn't exist.

func (*Store) GetPoints

func (s *Store) GetPoints(collectionName string) ([]vectorstore.Point, error)

GetPoints returns all points in a collection (for test assertions).

func (*Store) Search

func (s *Store) Search(ctx context.Context, collectionName string, vector []float32, topK int) ([]vectorstore.Result, error)

Search performs similarity search using cosine similarity.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, collectionName string, points []vectorstore.Point) error

Upsert inserts or updates points in a collection.

Jump to

Keyboard shortcuts

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