fabriqtest

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Overview

Package fabriqtest is fabriq's exported test kit.

Package fabriqtest is fabriq's exported test kit: in-memory fakes for every port, a combined World wiring them over shared memory, and (in later phases) the testcontainers harness and seeded fixtures.

Downstream services unit-test against these fakes; the same behavioral contracts are enforced on real adapters by the integration suites.

Index

Constants

View Source
const (
	PostgresImage = "timescale/timescaledb-ha:pg16-all"
	// PostgresPlainImage is the vanilla upstream Postgres image used for the
	// primary+standby replication harness (StartPrimaryStandby). It backs the
	// catalog control database — a single plain table with no pgvector/timescale
	// needs — and, unlike timescaledb-ha, has no HA entrypoint that fights
	// pg_basebackup-based standby setup.
	PostgresPlainImage = "postgres:16-alpine"
	RedisImage         = "redis:7-alpine"
	FalkorDBImage      = "falkordb/falkordb:v4.2.2" // pinned: multi-label + SET n:Label
	ElasticsearchImage = "elasticsearch:9.4.1"
	// ClickHouseImage pins a server new enough that lightweight DELETE is GA and
	// enabled by default (>= 23.3).
	ClickHouseImage = "clickhouse/clickhouse-server:24.3"
)

Container images for the integration harness. timescaledb-ha bundles TimescaleDB and pgvector, matching the production datastore contract.

Variables

View Source
var ErrFakeNotFound = fabriqerr.ErrNotFound

ErrFakeNotFound is the not-found error returned by fakes; it is the canonical fabriq ErrNotFound so errors.Is works either way.

Functions

func ApplyDDL added in v0.0.3

func ApplyDDL(t testing.TB, dsn string, stmts []string)

ApplyDDL executes the given statements against dsn as the connecting role (typically the superuser/owner DSN). It is the seam tests use to create application-defined materialization targets (e.g. domain.PagesDDL()) that are no longer part of fabriq's shipped migration chain. Apply it BEFORE CreateAppRole so the app role inherits grants on the new tables.

func CreateAppRole

func CreateAppRole(t testing.TB, superDSN string) string

CreateAppRole provisions a NON-superuser application role on a database previously started with StartPostgres and returns a DSN for it.

This mirrors production: migrations run as the schema owner; the application connects as a restricted role so RLS actually applies (Postgres row security NEVER constrains superusers). Call it AFTER running migrations.

func NewConformanceBackend

func NewConformanceBackend(t testing.TB) conformance.Backend

NewConformanceBackend builds a fake-backed conformance.Backend over the domain registry. It is the fast (Docker-free) gate that keeps the fakes from drifting from real-adapter behavior.

func NewFabric

func NewFabric(w *World) query.Fabric

NewFabric returns a query.Fabric backed by the World's in-memory fakes. Exec runs through a command.Executor on the World's store (so writes are visible through Relational). Subscribe returns a fresh buffered channel (no deltas are published unless a test drives the underlying fakes); WaitForProjection is a no-op.

func QueryStrings added in v0.0.6

func QueryStrings(t testing.TB, dsn, sql string, args ...any) []string

QueryStrings runs a single-column query against dsn and returns the rows as strings — the seam integration tests use for schema-shape assertions (information_schema / pg_catalog checks).

func RunCacheConformance

func RunCacheConformance(t *testing.T, newCache func(t *testing.T) cache.Cache)

RunCacheConformance is the single behavioral contract for cache.Cache. It is run against FakeCache (unit) and the grove-kv adapter (integration) so the two can never drift. newCache returns a fresh, empty cache per subtest.

func StartClickHouse added in v0.0.6

func StartClickHouse(t testing.TB) string

StartClickHouse launches a ClickHouse container and returns its clickhouse:// DSN. The container terminates with the test.

func StartElasticsearch

func StartElasticsearch(t testing.TB) string

StartElasticsearch launches a single-node Elasticsearch container (security off, HTTP only) and returns its base URL. The container terminates with the test.

func StartFalkorDB

func StartFalkorDB(t testing.TB) string

StartFalkorDB launches a FalkorDB container and returns its address (host:port). The container terminates with the test.

func StartPostgres

func StartPostgres(t testing.TB) string

StartPostgres launches a Postgres+Timescale+pgvector container and returns its DSN. The container terminates with the test.

func StartRedis

func StartRedis(t testing.TB) string

StartRedis launches a Redis container and returns its address (host:port). The container terminates with the test.

Types

type FakeAnalytics added in v0.0.6

type FakeAnalytics struct {
	// contains filtered or unexported fields
}

FakeAnalytics is an in-memory query.AnalyticsQuerier for tests. Events are keyed tenant-first so cross-tenant reads are structurally impossible.

func NewFakeAnalytics added in v0.0.6

func NewFakeAnalytics(reg *registry.Registry) *FakeAnalytics

NewFakeAnalytics returns an empty FakeAnalytics that resolves Query.Source against reg via insights.ResolveSource — the same resolver the real Postgres adapter uses, so routing (metric > entity > event) can't drift between the fake and the adapter. reg may be nil, in which case every source resolves to an event descriptor (the prior back-compat behavior).

func (*FakeAnalytics) Query added in v0.0.6

func (f *FakeAnalytics) Query(ctx context.Context, q query.AnalyticsQuery, into any) error

Query implements query.AnalyticsQuerier by aggregating in-memory: filter by Source/time-window/Filter, group by (Dimensions..., time bucket), fold Measures, order deterministically, and apply Limit. Output rows are marshaled into `into` (a *[]map[string]any) via a JSON round-trip.

func (*FakeAnalytics) QueryRaw added in v0.0.6

func (f *FakeAnalytics) QueryRaw(ctx context.Context, _ any, _ string, _ ...any) error

QueryRaw implements query.AnalyticsQuerier. Raw SQL has no in-memory analogue; the fake always errors. The conformance suite does not exercise this method — only the real adapter does.

func (*FakeAnalytics) Track added in v0.0.6

func (f *FakeAnalytics) Track(ctx context.Context, events []query.AnalyticsEvent) error

Track implements query.AnalyticsQuerier. Events sharing a non-empty DedupKey (scoped per tenant) after the first Track call are dropped.

func (*FakeAnalytics) UpsertInsightFacts added in v0.0.6

func (f *FakeAnalytics) UpsertInsightFacts(ctx context.Context, facts []insights.Fact) error

UpsertInsightFacts implements insights.FactSink: an in-memory, version- gated upsert keyed tenant|entity|aggID, mirroring the real adapter's (tenant_id, entity, agg_id) uniqueness + "WHERE EXCLUDED.version > fabriq_insights_facts.version" gate (adapters/postgres/insights.go's UpsertInsightFacts) — an equal-or-older version is a silent no-op, never an error, so redelivery from the proj:insights consumer stays idempotent.

type FakeAnalyticsSink added in v0.0.6

type FakeAnalyticsSink struct {
	// contains filtered or unexported fields
}

FakeAnalyticsSink is an in-memory analytics.Sink with the same idempotency semantics as the Postgres adapter. It is the conformance twin used to unit-test the applier, consumer, and backfill without Docker.

func NewFakeAnalyticsSink added in v0.0.6

func NewFakeAnalyticsSink() *FakeAnalyticsSink

func (*FakeAnalyticsSink) AllWatermarks added in v0.0.6

func (s *FakeAnalyticsSink) AllWatermarks(_ context.Context, tenantID string) ([]analytics.Watermark, error)

AllWatermarks returns every applied watermark for a tenant.

func (*FakeAnalyticsSink) AppendEvents added in v0.0.6

func (s *FakeAnalyticsSink) AppendEvents(_ context.Context, events []analytics.Event) error

func (*FakeAnalyticsSink) Close added in v0.0.6

func (s *FakeAnalyticsSink) Close() error

func (*FakeAnalyticsSink) Events added in v0.0.6

func (s *FakeAnalyticsSink) Events() map[string]analytics.Event

Events returns a snapshot of all appended events (test inspection).

func (*FakeAnalyticsSink) Facts added in v0.0.6

func (s *FakeAnalyticsSink) Facts() map[string]analytics.Fact

Facts returns a snapshot keyed by tenant|aggregate|aggID (test inspection).

func (*FakeAnalyticsSink) LagByTenant added in v0.0.6

func (s *FakeAnalyticsSink) LagByTenant(_ context.Context) (map[string]float64, error)

LagByTenant returns now() - (that tenant's newest fact At) per tenant.

func (*FakeAnalyticsSink) MaintainPartitions added in v0.0.6

func (s *FakeAnalyticsSink) MaintainPartitions(_ context.Context, _ time.Duration) (created, dropped int, err error)

MaintainPartitions is a no-op for the in-memory fake (it does not partition).

func (*FakeAnalyticsSink) PruneEvents added in v0.0.6

func (s *FakeAnalyticsSink) PruneEvents(_ context.Context, olderThan time.Time) (int64, error)

PruneEvents deletes history events older than olderThan across all tenants.

func (*FakeAnalyticsSink) PurgeTenant added in v0.0.6

func (s *FakeAnalyticsSink) PurgeTenant(_ context.Context, tenantID string) (int64, error)

PurgeTenant hard-deletes every fact, event, and watermark for one tenant and returns the count removed. Idempotent.

func (*FakeAnalyticsSink) ReprojectTenant added in v0.0.6

func (s *FakeAnalyticsSink) ReprojectTenant(_ context.Context, tenantID, aggregate string, transform func(json.RawMessage) (json.RawMessage, error)) (int64, error)

ReprojectTenant re-projects stored fact and event payloads for a tenant (and optional aggregate) through transform, in place, returning the count changed.

func (*FakeAnalyticsSink) SetWatermark added in v0.0.6

func (s *FakeAnalyticsSink) SetWatermark(_ context.Context, ws []analytics.Watermark) error

func (*FakeAnalyticsSink) UpsertFacts added in v0.0.6

func (s *FakeAnalyticsSink) UpsertFacts(_ context.Context, facts []analytics.Fact) error

func (*FakeAnalyticsSink) Watermark added in v0.0.6

func (s *FakeAnalyticsSink) Watermark(_ context.Context, tenant, agg, id string) (int64, error)

type FakeBlob

type FakeBlob struct {
	// contains filtered or unexported fields
}

FakeBlob is an in-memory, tenant-scoped blob.Store for tests. It implements only the core Store surface — no capability sub-interfaces — so Caps reports all false and capability-gated conformance cases skip.

func NewFakeBlob

func NewFakeBlob() *FakeBlob

NewFakeBlob creates an empty in-memory blob store.

func (*FakeBlob) Capabilities

func (f *FakeBlob) Capabilities() blob.Caps

func (*FakeBlob) Copy

func (f *FakeBlob) Copy(ctx context.Context, srcKey, dstKey string) (blob.ObjectInfo, error)

func (*FakeBlob) Delete

func (f *FakeBlob) Delete(ctx context.Context, key string) error

func (*FakeBlob) Get

func (*FakeBlob) Head

func (f *FakeBlob) Head(ctx context.Context, key string) (blob.ObjectInfo, error)

func (*FakeBlob) List

func (f *FakeBlob) List(ctx context.Context, prefix string) ([]blob.ObjectInfo, error)

func (*FakeBlob) Put

func (f *FakeBlob) Put(ctx context.Context, key string, r io.Reader, o blob.PutOpts) (blob.ObjectInfo, error)

type FakeCAS

type FakeCAS struct {
	// contains filtered or unexported fields
}

FakeCAS is an in-memory content-addressed store for hermetic tests. It implements blob.CAS, dedups by sha256, and is tenant-agnostic.

func NewFakeCAS

func NewFakeCAS() *FakeCAS

NewFakeCAS builds an empty FakeCAS.

func (*FakeCAS) Has

func (c *FakeCAS) Has(hash string) bool

Has reports whether a hash is present.

func (*FakeCAS) Len

func (c *FakeCAS) Len() int

Len returns the number of distinct stored blobs.

func (*FakeCAS) Retrieve

func (c *FakeCAS) Retrieve(_ context.Context, hash string) (io.ReadCloser, error)

Retrieve returns the bytes for a hash.

func (*FakeCAS) Store

func (c *FakeCAS) Store(_ context.Context, r io.Reader) (hash string, size int64, err error)

Store writes content-addressed bytes and returns the sha256 hex hash.

type FakeCache

type FakeCache struct {
	// contains filtered or unexported fields
}

FakeCache is an in-memory cache.Cache for unit tests. It implements the same behavioral contract (RunCacheConformance) as the real grove-kv adapter: scope isolation, generation invalidation, single-flight GetOrLoad, TTL.

func NewFakeCache

func NewFakeCache() *FakeCache

NewFakeCache builds an empty in-memory cache.

func (*FakeCache) Close

func (c *FakeCache) Close() error

func (*FakeCache) Get

func (c *FakeCache) Get(ctx context.Context, ks cache.Keyspace, key string) (val []byte, ok bool, err error)

func (*FakeCache) GetOrLoad

func (c *FakeCache) GetOrLoad(ctx context.Context, ks cache.Keyspace, key string,
	load func(context.Context) ([]byte, error)) ([]byte, error)

func (*FakeCache) Invalidate

func (c *FakeCache) Invalidate(ctx context.Context, ks cache.Keyspace, keys ...string) error

func (*FakeCache) InvalidateEntity

func (c *FakeCache) InvalidateEntity(ctx context.Context, entity string) error

InvalidateEntity bumps the entity generation for Global + Tenant + (if present) TenantScope partitions, mirroring the adapter.

func (*FakeCache) InvalidateKeyspace

func (c *FakeCache) InvalidateKeyspace(ctx context.Context, ks cache.Keyspace) error

func (*FakeCache) Set

func (c *FakeCache) Set(ctx context.Context, ks cache.Keyspace, key string, val []byte) error

type FakeCatalog added in v0.0.6

type FakeCatalog struct {
	// contains filtered or unexported fields
}

FakeCatalog is the in-memory tenant catalog (catalog.Catalog): the deterministic control plane the db-per-tenant router, provisioner and sweeper are unit-tested against. Semantics are pinned by the shared contract suite (core/catalog/catalogtest), which the Postgres control store must also pass.

func NewFakeCatalog added in v0.0.6

func NewFakeCatalog() *FakeCatalog

NewFakeCatalog returns an empty catalog.

func (*FakeCatalog) Get added in v0.0.6

func (f *FakeCatalog) Get(_ context.Context, tenantID string) (catalog.Entry, error)

Get implements catalog.Catalog.

func (*FakeCatalog) List added in v0.0.6

func (f *FakeCatalog) List(_ context.Context, cursor catalog.Cursor, limit int) ([]catalog.Entry, catalog.Cursor, error)

List implements catalog.Catalog: stable tenant-id order, opaque cursor.

func (*FakeCatalog) Put added in v0.0.6

Put implements catalog.Catalog (optimistic concurrency on UpdatedAt).

type FakeDocumentStore

type FakeDocumentStore struct {
	// contains filtered or unexported fields
}

FakeDocumentStore is a real in-memory document plane: an append-only per-doc update log with monotonic seqs, seq-vector Sync (snapshot + tail, mirroring the postgres wire shape), grove-engine folds via crdt.ApplyChange, and log-into-snapshot compaction — the contract suite in core/document runs against it.

It additionally implements the optional history-offload capabilities (document.SegmentLister, document.HistoryReader, document.HistoryPurger) against in-memory seeded state, so adminapi handlers that type-assert for those capabilities can be unit-tested without a real offload-backed store. Tests seed state via SeedSegments/SeedHistory and observe purges via DeletedHistory.

func (*FakeDocumentStore) ApplyUpdate

func (f *FakeDocumentStore) ApplyUpdate(_ context.Context, docID string, update []byte) error

ApplyUpdate implements document.Store: append one encoded update (a non-empty JSON []crdt.ChangeRecord) to the doc's log.

func (*FakeDocumentStore) Compact

func (f *FakeDocumentStore) Compact(_ context.Context, docID string) error

Compact implements document.Store: fold the log into the snapshot and trim it (storage-only; Sync output is unchanged).

func (*FakeDocumentStore) DeleteHistory added in v0.0.4

func (f *FakeDocumentStore) DeleteHistory(_ context.Context, docID string) error

DeleteHistory implements document.HistoryPurger: it clears docID's seeded segments and history and records the purge for DeletedHistory to observe.

func (*FakeDocumentStore) DeletedHistory added in v0.0.4

func (f *FakeDocumentStore) DeletedHistory(docID string) bool

DeletedHistory reports whether DeleteHistory has been called for docID.

func (*FakeDocumentStore) ListSegments added in v0.0.4

func (f *FakeDocumentStore) ListSegments(_ context.Context, docID string) ([]document.SegmentInfo, error)

ListSegments implements document.SegmentLister over seeded state.

func (*FakeDocumentStore) ReadHistory added in v0.0.4

func (f *FakeDocumentStore) ReadHistory(_ context.Context, docID string, seqLo, seqHi int64) ([]document.HistoryUpdate, error)

ReadHistory implements document.HistoryReader over seeded state, filtering to updates with seqLo <= seq <= seqHi and returning them in seq order.

func (*FakeDocumentStore) SeedHistory added in v0.0.4

func (f *FakeDocumentStore) SeedHistory(docID string, ups []document.HistoryUpdate)

SeedHistory seeds the raw update history ReadHistory filters over for docID, replacing any previously seeded history for that doc.

func (*FakeDocumentStore) SeedSegments added in v0.0.4

func (f *FakeDocumentStore) SeedSegments(docID string, segs []document.SegmentInfo)

SeedSegments seeds the sealed-segment metadata ListSegments returns for docID, replacing any previously seeded segments for that doc.

func (*FakeDocumentStore) Snapshot

Snapshot implements document.Store: merged state projected onto column-keyed values.

func (*FakeDocumentStore) Sync

func (f *FakeDocumentStore) Sync(_ context.Context, docID string, stateVector []byte) ([]byte, error)

Sync implements document.Store: 8-byte big-endian last-seen seq in, JSON {seq, snapshot?, updates[]} out (snapshot when the client is behind the compaction floor) — the postgres adapter's wire shape.

type FakeGraph

type FakeGraph struct {
	// contains filtered or unexported fields
}

FakeGraph applies engine-neutral mutations to an in-memory property graph with the same version gating real adapters implement, and serves canned responses for raw Cypher (fakes do not parse Cypher).

func NewFakeGraph

func NewFakeGraph(reg *registry.Registry, rel query.RelationalQuerier) *FakeGraph

NewFakeGraph builds a graph fake hydrating through rel.

func (*FakeGraph) ApplyMutations

func (g *FakeGraph) ApplyMutations(ctx context.Context, target string, muts []projection.Mutation) error

ApplyMutations implements the projection write path with version gating. target "" resolves to the tenant's live graph (tenant from ctx), the same contract real sinks implement.

func (*FakeGraph) Cann

func (g *FakeGraph) Cann(cypher string, ids []string)

Cann registers the id list a Cypher string returns (exact match).

func (*FakeGraph) HasEdge

func (g *FakeGraph) HasEdge(target, rel, fromLabel, fromID, toLabel, toID string) bool

HasEdge inspects an edge in a target graph.

func (*FakeGraph) Node

func (g *FakeGraph) Node(target, label, id string) (FakeNode, bool)

Node inspects a node in a target graph.

func (*FakeGraph) Query

func (g *FakeGraph) Query(_ context.Context, cypher string, _ map[string]any, into any) error

Query implements query.GraphQuerier for canned traversals.

func (*FakeGraph) TraverseAndHydrate

func (g *FakeGraph) TraverseAndHydrate(ctx context.Context, cypher string, params map[string]any, into any) error

TraverseAndHydrate composes the canned traversal with one batched relational hydration (the no-N+1 contract).

type FakeNode

type FakeNode struct {
	Props   map[string]any
	Version int64
}

FakeNode is an inspectable graph node.

type FakeProjectionState

type FakeProjectionState struct {
	// contains filtered or unexported fields
}

FakeProjectionState tracks applied versions per aggregate for WaitForProjection tests; projection consumers (or tests) advance it with SetApplied.

func (*FakeProjectionState) AppliedVersion

func (f *FakeProjectionState) AppliedVersion(_ context.Context, tenantID, proj, aggregate, aggID string) (int64, error)

AppliedVersion implements projection.StateReader.

func (*FakeProjectionState) SetApplied

func (f *FakeProjectionState) SetApplied(_ context.Context, tenantID, proj, aggregate, aggID string, version int64) error

SetApplied records that a projection has applied an aggregate version (implements projection.AppliedRecorder; the watermark never regresses).

type FakeRelational

type FakeRelational struct {
	// contains filtered or unexported fields
}

FakeRelational reads the world's shared memory, tenant-scoped from ctx.

func (*FakeRelational) Get

func (r *FakeRelational) Get(ctx context.Context, entity, id string, into any) error

Get implements query.RelationalQuerier.

func (*FakeRelational) GetMany

func (r *FakeRelational) GetMany(ctx context.Context, entity string, ids []string, into any) error

GetMany implements the batched hydration contract: one logical lookup, results in ids order, missing ids skipped.

func (*FakeRelational) List

func (r *FakeRelational) List(ctx context.Context, entity string, q query.ListQuery, into any) error

List implements equality-filtered paging.

func (*FakeRelational) Query

func (r *FakeRelational) Query(context.Context, any, string, ...any) error

Query is unsupported in the fake — raw SQL belongs to integration tests against the real adapter. Callers may detect this via errors.Is(err, fabriqerr.ErrRawSQLUnsupported) and fall back to a portable List/Get-based read.

type FakeSearch

type FakeSearch struct {
	// contains filtered or unexported fields
}

FakeSearch is a substring-matching search fake with version gating and ctx-tenant scoping.

func NewFakeSearch

func NewFakeSearch(reg *registry.Registry) *FakeSearch

NewFakeSearch builds a search fake.

func (*FakeSearch) ApplyMutations

func (s *FakeSearch) ApplyMutations(_ context.Context, _ string, muts []projection.Mutation) error

ApplyMutations implements the projection write path.

func (*FakeSearch) Search

func (s *FakeSearch) Search(ctx context.Context, q query.SearchQuery, into any) error

Search implements substring match over the entity's declared fields, narrowed by the structured Filter, ordered by Sort (id when empty, since the fake has no relevance score) and paginated by Offset/Limit. It mirrors the ES adapter's neutral contract closely enough for unit tests; the integration suite is the source of truth for scoring and analysis.

type FakeSpatial

type FakeSpatial struct {
	// contains filtered or unexported fields
}

FakeSpatial is an exact in-memory geometry store that implements query.SpatialQuerier. It is tenant-scoped via ctx and safe for concurrent use. Distance computation is haversine for SRID 4326, planar Euclidean otherwise.

func (*FakeSpatial) Delete

func (f *FakeSpatial) Delete(ctx context.Context, entity, id string) error

Delete implements query.SpatialQuerier.

func (*FakeSpatial) Get added in v0.0.5

func (f *FakeSpatial) Get(ctx context.Context, entity, id string) (geom query.Geometry, meta map[string]any, ok bool, err error)

Get implements query.SpatialQuerier. Returns ok=false (nil error) when the id is absent, out of scope, or stored as a non-point (NaN) geometry.

func (*FakeSpatial) Upsert

func (f *FakeSpatial) Upsert(ctx context.Context, entity, id string, geom query.Geometry, meta map[string]any) error

Upsert implements query.SpatialQuerier.

func (*FakeSpatial) Within

func (f *FakeSpatial) Within(ctx context.Context, q query.SpatialQuery, into any) error

Within implements query.SpatialQuerier. Results are scanned into *[]query.SpatialMatch, nearest-first; ties break by ID.

type FakeStore

type FakeStore struct {
	// contains filtered or unexported fields
}

FakeStore implements command.Store with real transactional semantics: changes stage into a snapshot and merge only on success, so batch atomicity behaves like the Postgres adapter.

func (*FakeStore) FailOnOutbox

func (s *FakeStore) FailOnOutbox(fn func() error)

FailOnOutbox injects an outbox failure (nil to clear).

func (*FakeStore) InTenantTx

func (s *FakeStore) InTenantTx(ctx context.Context, fn func(ctx context.Context, tx command.Tx) error) error

InTenantTx implements command.Store. Fakes run transactions one at a time; concurrency tests belong to the real adapter's integration suite.

func (*FakeStore) Outbox

func (s *FakeStore) Outbox() []event.Envelope

Outbox returns every envelope committed so far, in order.

type FakeTS

type FakeTS struct {
	// contains filtered or unexported fields
}

FakeTS stores points per (tenant, series, key), time-sorted.

func (*FakeTS) BulkWrite

func (f *FakeTS) BulkWrite(ctx context.Context, series string, points []query.Point) error

BulkWrite implements the event-bypass telemetry ingest.

func (*FakeTS) Range

func (f *FakeTS) Range(ctx context.Context, q query.RangeQuery, into any) error

Range implements raw-point reads over [From, To).

type FakeVector

type FakeVector struct {
	// contains filtered or unexported fields
}

FakeVector is an exact cosine-similarity store.

func (*FakeVector) Delete

func (f *FakeVector) Delete(ctx context.Context, entity, id string) error

Delete implements query.VectorQuerier.

func (*FakeVector) DeleteByMeta added in v0.0.3

func (f *FakeVector) DeleteByMeta(ctx context.Context, entity string, filter map[string]string) error

DeleteByMeta implements query.VectorQuerier.

func (*FakeVector) Get added in v0.0.3

func (f *FakeVector) Get(ctx context.Context, entity, id string) ([]float32, error)

Get implements query.VectorQuerier. Returns a copy of the stored embedding for (entity, id), or *fabriqerr.NotFoundError on miss.

func (*FakeVector) Similar

func (f *FakeVector) Similar(ctx context.Context, q query.VectorQuery, into any) error

Similar implements exact top-K cosine search.

func (*FakeVector) Upsert

func (f *FakeVector) Upsert(ctx context.Context, entity, id string, embedding []float32, meta map[string]any) error

Upsert implements query.VectorQuerier.

type World

type World struct {
	Registry    *registry.Registry
	Store       *FakeStore
	Rel         *FakeRelational
	Graph       *FakeGraph
	Search      *FakeSearch
	TS          *FakeTS
	Vector      *FakeVector
	Spatial     *FakeSpatial
	Docs        *FakeDocumentStore
	Projections *FakeProjectionState
	Blob        *FakeBlob
	Analytics   *FakeAnalytics
}

World wires all fakes over one shared in-memory store, so a command executed against Store is immediately visible through Rel, and graph / search fakes can hydrate from the same rows.

func NewWorld

func NewWorld(reg *registry.Registry) *World

NewWorld builds the linked fake set for a registry.

func (*World) Executor

func (w *World) Executor() *command.Executor

Executor returns a command executor wired to the world's store.

Jump to

Keyboard shortcuts

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