Documentation
¶
Overview ¶
Package storetest provides conformance suites for vector stores and filters.
Run checks the exact capability set and validation before external I/O. Undeclared and missing capabilities both fail; a no-op Close is not cleanup. VisitorConformance checks filter compilation and VisitorLifecycle checks reuse after failure. Provider tests own exact wire assertions. FilterConformance runs isolated backend queries and compares selected IDs with exact expectations and filter.Match. Its callback must query the backend, not evaluate the predicate locally. Unsupported semantics need classified errors. ProvenanceConformance checks source fidelity and isolation from metadata filters.
Field identifiers ¶
Schema-required backends assign one fixed type to each field:
author - string year - number published - bool n, a, b, c, d - number tags - string list years - number list flags - bool list title - string pattern profile['author'], profile['a']['b'] - keyed access tags[0], profile['a'][0], items[0]['name'] - array element access
Compiler options ¶
Options.InterpolatesKeyPaths distinguishes keys inserted into query syntax from bound values. The former must reject unsafe names; the latter must preserve arbitrary keys.
Options.CompileText checks numerals without lossy scalar conversions and that an array index never renders as the matching digit key. Options.NumericDomainIsFloat64 permits equivalent float64 representations when that is the backend's numeric domain.
Options.Unsupported names real capability gaps; each must fail explicitly.
Example ¶
package main
import (
"fmt"
"github.com/Tangerg/scope/core/vectorstore/storetest"
)
func main() {
capabilities := storetest.Capabilities{Upserter: true, Querier: true}
fmt.Println(capabilities.Upserter, capabilities.Querier)
}
Output: true true
Index ¶
- func FilterConformance(t *testing.T, config FilterConfig)
- func ProvenanceConformance(t *testing.T, ...)
- func Run(t *testing.T, store any, expected Capabilities)
- func VisitorConformance(t *testing.T, build BuildFn, options Options)
- func VisitorLifecycle(t *testing.T, factory func() Compiler)
- type BuildFn
- type Capabilities
- type Compiler
- type FilterConfig
- type Options
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterConformance ¶ added in v0.24.0
func FilterConformance(t *testing.T, config FilterConfig)
FilterConformance compares backend selection with filter.Match and exact expected IDs. It covers every operator, null/missing fields, array-index versus object-key selection, and LIKE's case, whole-value and Unicode wildcard semantics. Unlike Run, it executes queries and requires isolated fixtures; it never opens a provider connection itself.
func ProvenanceConformance ¶ added in v0.59.0
func ProvenanceConformance(t *testing.T, roundTrip func(*testing.T, *document.Document, filter.Predicate) (*vectorstore.SearchResponse, error))
ProvenanceConformance checks that typed source identity and locations survive a storage round trip without becoming searchable business fields. roundTrip writes the supplied document to an isolated store and queries it with the given predicate, using either native selection or an explicit budgeted scan.
func Run ¶
func Run(t *testing.T, store any, expected Capabilities)
Run verifies the backend's exact capability set and the common operations that must complete before external I/O. Pass a non-nil zero-value *Store; the calls below must not reach provider dependencies.
func VisitorLifecycle ¶
VisitorLifecycle verifies that a compiler resets before every visit and remains reusable after rejecting a malformed predicate.
Types ¶
type Capabilities ¶
type Capabilities struct {
Upserter bool
Querier bool
IDDeleter bool
FilterDeleter bool
// Closer is true only when the store owns a resource it must release.
// A store using caller-owned resources must not expose a no-op Close.
Closer bool
}
Capabilities is the exact set of operations a backend implements. Native mode, filter and media constraints are checked on a configured store; these depend on its bound schema, not on method presence.
func CapabilitiesOf ¶ added in v0.16.0
func CapabilitiesOf(store any) Capabilities
CapabilitiesOf detects the operations implemented by store.
type FilterConfig ¶ added in v0.24.0
type FilterConfig struct {
// Query installs exactly documents in an isolated fixture, executes predicate
// through the backend, and returns all selected document IDs. It must not
// evaluate predicate with filter.Match or substitute expected responses.
// The caller owns fixture cleanup and provider visibility synchronization.
// Documents have UUID IDs and identical text; search adapters must request
// at least len(documents) results without a relevance threshold.
Query func(context.Context, []*document.Document, filter.Predicate) ([]string, error)
// Unsupported maps corpus case names to the error identifying the backend's
// explicit refusal. Each case must return that error via errors.Is and no
// IDs. Unknown names and nil errors fail; transport errors cannot stand in
// for unsupported semantics.
Unsupported map[string]error
}
FilterConfig connects the semantic corpus to a backend's query boundary.
type Options ¶
type Options struct {
// Unsupported cases must return an error; approximation and skipping are forbidden.
// A backend that cannot select array elements with filter.Match semantics
// declares array_index, nested_array_index, and array_index_key.
Unsupported []string
// InterpolatesKeyPaths declares that keys are written as query syntax.
// Such compilers must reject keys the language cannot name safely; compilers
// that bind keys as values must preserve arbitrary keys.
InterpolatesKeyPaths bool
// Set CompileText when the emitted query is text so the suite can verify
// numerals retain their exact value. Leave it nil for bound arguments or
// provider structures; rendering those solely for this check would test a
// representation the backend never receives.
CompileText func(source string) (string, error)
// NumericDomainIsFloat64 requires equal float64 values instead of equal
// integer digits, matching the precision of providers that store doubles.
NumericDomainIsFloat64 bool
}