providertest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package providertest provides conformance tests for memory provider implementations.

Provider implementations can use this package to verify they correctly implement the core.Provider interface with consistent behavior.

Basic usage:

func TestConformance(t *testing.T) {
    store := kvsmemory.New()
    p, _ := kvs.NewProvider(core.ProviderConfig{
        Options: map[string]any{"store": store},
    }, nil)

    providertest.RunAll(t, providertest.Config{
        Provider: p,
    })
}

For providers requiring API credentials (like Twilio):

func TestConformance(t *testing.T) {
    if os.Getenv("TWILIO_ACCOUNT_SID") == "" {
        t.Skip("TWILIO_ACCOUNT_SID not set")
    }

    p, _ := NewProvider(core.ProviderConfig{}, nil)

    providertest.RunAll(t, providertest.Config{
        Provider:        p,
        SkipIntegration: false,
        TenantID:        "your-store-id",
        SubjectID:       "your-profile-id",
    })
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAll

func RunAll(t *testing.T, cfg Config)

RunAll runs all conformance tests for a memory provider.

func RunBehaviorTests

func RunBehaviorTests(t *testing.T, cfg Config)

RunBehaviorTests runs behavioral contract tests.

func RunCRUDTests

func RunCRUDTests(t *testing.T, cfg Config)

RunCRUDTests runs CRUD operation tests.

func RunInterfaceTests

func RunInterfaceTests(t *testing.T, cfg Config)

RunInterfaceTests runs only interface compliance tests. These tests verify the provider correctly implements the interface contract.

func RunSearchTests

func RunSearchTests(t *testing.T, cfg Config)

RunSearchTests runs search and recall tests.

Types

type Config

type Config struct {
	// Provider is the memory provider implementation to test.
	Provider core.Provider

	// Embedder is an optional embedder for testing semantic search.
	// If nil, search tests will verify behavior without embeddings.
	Embedder core.Embedder

	// SkipIntegration skips tests that require real API calls.
	// Set to true for local-only providers (memory, kvs, postgres).
	SkipIntegration bool

	// TenantID is the tenant ID to use for tests.
	// Defaults to "test-tenant" if empty.
	TenantID string

	// SubjectID is the subject ID to use for tests.
	// Defaults to "test-subject" if empty.
	SubjectID string

	// Timeout for individual test operations.
	// Defaults to 30 seconds if zero.
	Timeout time.Duration
}

Config configures the memory provider conformance test suite.

Jump to

Keyboard shortcuts

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