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.
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 metadata['author'], metadata['a']['b'] - keyed 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. 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{Indexer: true, Searcher: true}
fmt.Println(capabilities.Indexer, capabilities.Searcher)
}
Output: true true
Index ¶
- func FilterConformance(t *testing.T, config FilterConfig)
- 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, 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 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 {
Indexer bool
Searcher bool
HybridSearch bool
// MediaDocuments declares lossless storage of document media alongside text.
// A false value requires rejection of mixed content before external I/O.
MediaDocuments 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 interface, content, and search-semantics set a backend promises. A false interface flag forbids accidental implementation; a false HybridSearch flag requires rejection before external I/O.
func CapabilitiesOf ¶ added in v0.16.0
func CapabilitiesOf(store any) Capabilities
CapabilitiesOf detects interface capabilities. Run probes HybridSearch and MediaDocuments through operations because no interface expresses them.
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.
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
}