testutil

package
v0.0.0-...-d80aada Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package testing provides test cluster management inspired by CockroachDB

Package testutil provides test configuration management

Package testutil provides embedding vector simulator for testing

Package testutil provides test utilities and fixtures for memory system

Package testutil provides retry mechanisms for testing

Package testutil provides test skip conditions

Package testing provides integration testing utilities for the memory system

Package testutil provides async test waiting utilities

Index

Constants

This section is empty.

Variables

View Source
var CorrectionTestCases = []struct {
	Name       string
	Original   MemoryFixture
	Correction MemoryFixture
	Reason     string
}{
	{
		Name:       "preference_correction",
		Original:   Scenarios.OriginalMemory,
		Correction: Scenarios.CorrectedMemory,
		Reason:     "使用者糾正偏好",
	},
	{
		Name: "fact_update",
		Original: MemoryFixture{
			ID:         uuid.MustParse("dddd1111-dddd-1111-dddd-111111111111"),
			Content:    "我住在台北",
			Type:       "location",
			Confidence: 0.8,
		},
		Correction: MemoryFixture{
			ID:         uuid.MustParse("dddd2222-dddd-2222-dddd-222222222222"),
			Content:    "我搬到高雄了",
			Type:       "location",
			Confidence: 0.95,
		},
		Reason: "位置更新",
	},
}

CorrectionTestCases defines correction flow test cases

View Source
var DefaultRetryOptions = RetryOptions{
	MaxAttempts:  3,
	InitialDelay: 100 * time.Millisecond,
	MaxDelay:     5 * time.Second,
	Multiplier:   2.0,
}

DefaultRetryOptions provides default retry configuration

View Source
var DefaultWaitOptions = WaitOptions{
	Timeout:  5 * time.Second,
	Interval: 100 * time.Millisecond,
}

DefaultWaitOptions provides default wait configuration

View Source
var Scenarios = struct {
	// Basic scenarios
	SimpleMemory     MemoryFixture
	PersonalInfo     MemoryFixture
	PreferenceMemory MemoryFixture

	// Complex content scenarios
	LongContent    MemoryFixture
	UnicodeContent MemoryFixture
	JSONContent    MemoryFixture

	// Entity scenarios
	WithPerson       MemoryFixture
	WithOrganization MemoryFixture
	MultipleEntities MemoryFixture

	// Correction scenarios
	OriginalMemory  MemoryFixture
	CorrectedMemory MemoryFixture

	// Edge case scenarios
	EmptyContent      MemoryFixture
	VeryLowConfidence MemoryFixture
	MaxConfidence     MemoryFixture

	// Concurrent test scenarios
	ConcurrentMemories []MemoryFixture
}{

	SimpleMemory: MemoryFixture{
		ID:         uuid.MustParse("11111111-1111-1111-1111-111111111111"),
		Content:    "這是一個簡單的測試記憶",
		Type:       "fact",
		Tags:       []string{"test", "simple"},
		Confidence: 0.9,
		Source:     "user_direct",
	},

	PersonalInfo: MemoryFixture{
		ID:         uuid.MustParse("22222222-2222-2222-2222-222222222222"),
		Content:    "我的生日是5月1日",
		Type:       "personal_info",
		Tags:       []string{"birthday", "date", "personal"},
		Confidence: 0.95,
		Source:     "user_direct",
	},

	PreferenceMemory: MemoryFixture{
		ID:         uuid.MustParse("33333333-3333-3333-3333-333333333333"),
		Content:    "我喜歡喝咖啡",
		Type:       "preference",
		Tags:       []string{"coffee", "beverage", "preference"},
		Confidence: 0.85,
		Source:     "user_confirm",
	},

	LongContent: MemoryFixture{
		ID: uuid.MustParse("44444444-4444-4444-4444-444444444444"),
		Content: `這是一個非常長的記憶內容,用於測試系統處理長文本的能力。
		在實際應用中,使用者可能會提供詳細的背景資訊、故事或解釋。
		系統需要能夠正確處理、儲存和檢索這些長內容。
		這個測試資料包含多行文字,特殊字元,以及各種標點符號!
		我們要確保系統能夠:
		1. 正確儲存完整內容
		2. 保持格式不變
		3. 支援有效的搜尋
		4. 處理特殊字元如 @#$%^&*()
		5. 支援多語言:English, 中文, 日本語, 한국어`,
		Type:       "fact",
		Tags:       []string{"long", "multiline", "special-chars"},
		Confidence: 0.8,
		Source:     "assistant_infer",
	},

	UnicodeContent: MemoryFixture{
		ID:         uuid.MustParse("55555555-5555-5555-5555-555555555555"),
		Content:    "測試 Unicode:😀🎉 數學符號:∑∫∂ 特殊字元:™®© 音標:[ˈjuːnɪˌkoʊd]",
		Type:       "fact",
		Tags:       []string{"unicode", "emoji", "symbols"},
		Confidence: 0.75,
		Source:     "user_direct",
	},

	JSONContent: MemoryFixture{
		ID:         uuid.MustParse("66666666-6666-6666-6666-666666666666"),
		Content:    `{"key": "value", "nested": {"data": true}, "array": [1, 2, 3]}`,
		Type:       "fact",
		Tags:       []string{"json", "structured"},
		Confidence: 0.9,
		Source:     "system",
	},

	WithPerson: MemoryFixture{
		ID:      uuid.MustParse("77777777-7777-7777-7777-777777777777"),
		Content: "Koopa是我的同事",
		Type:    "relationship",
		Tags:    []string{"person", "colleague"},
		Entities: []Entity{
			{Name: "Koopa", Type: "person"},
		},
		Confidence: 0.88,
		Source:     "user_direct",
	},

	WithOrganization: MemoryFixture{
		ID:      uuid.MustParse("88888888-8888-8888-8888-888888888888"),
		Content: "我在 Google 工作",
		Type:    "work",
		Tags:    []string{"work", "company"},
		Entities: []Entity{
			{Name: "Google", Type: "organization"},
		},
		Confidence: 0.92,
		Source:     "user_direct",
	},

	MultipleEntities: MemoryFixture{
		ID:      uuid.MustParse("99999999-9999-9999-9999-999999999999"),
		Content: "李四和王五都在微軟工作,他們住在台北",
		Type:    "fact",
		Tags:    []string{"people", "work", "location"},
		Entities: []Entity{
			{Name: "李四", Type: "person"},
			{Name: "王五", Type: "person"},
			{Name: "微軟", Type: "organization"},
			{Name: "台北", Type: "location"},
		},
		Confidence: 0.85,
		Source:     "user_confirm",
	},

	OriginalMemory: MemoryFixture{
		ID:         uuid.MustParse("aaaa1111-aaaa-1111-aaaa-111111111111"),
		Content:    "我喜歡紅茶",
		Type:       "preference",
		Tags:       []string{"tea", "beverage", "red"},
		Confidence: 0.8,
		Source:     "user_direct",
		CorrectedBy: func() *uuid.UUID {
			id := uuid.MustParse("aaaa2222-aaaa-2222-aaaa-222222222222")
			return &id
		}(),
	},

	CorrectedMemory: MemoryFixture{
		ID:         uuid.MustParse("aaaa2222-aaaa-2222-aaaa-222222222222"),
		Content:    "我喜歡綠茶",
		Type:       "preference",
		Tags:       []string{"tea", "beverage", "green"},
		Confidence: 0.95,
		Source:     "user_correction",
		Supersedes: []uuid.UUID{
			uuid.MustParse("aaaa1111-aaaa-1111-aaaa-111111111111"),
		},
	},

	EmptyContent: MemoryFixture{
		ID:         uuid.MustParse("bbbb1111-bbbb-1111-bbbb-111111111111"),
		Content:    "",
		Type:       "fact",
		Tags:       []string{},
		Confidence: 0.5,
		Source:     "system",
	},

	VeryLowConfidence: MemoryFixture{
		ID:         uuid.MustParse("bbbb2222-bbbb-2222-bbbb-222222222222"),
		Content:    "不確定的資訊",
		Type:       "fact",
		Tags:       []string{"uncertain"},
		Confidence: 0.1,
		Source:     "assistant_infer",
	},

	MaxConfidence: MemoryFixture{
		ID:         uuid.MustParse("bbbb3333-bbbb-3333-bbbb-333333333333"),
		Content:    "絕對確定的資訊",
		Type:       "fact",
		Tags:       []string{"certain"},
		Confidence: 1.0,
		Source:     "user_direct",
	},

	ConcurrentMemories: generateConcurrentFixtures(),
}

Scenarios contains fixtures for various test scenarios

View Source
var SearchTestCases = []struct {
	Name          string
	Query         string
	ExpectedCount int
	ExpectedIDs   []uuid.UUID
	ExpectedOrder bool // Whether to verify order
}{
	{
		Name:          "search_birthday",
		Query:         "生日",
		ExpectedCount: 1,
		ExpectedIDs: []uuid.UUID{
			uuid.MustParse("22222222-2222-2222-2222-222222222222"),
		},
	},
	{
		Name:          "search_beverage",
		Query:         "茶",
		ExpectedCount: 2,
		ExpectedIDs: []uuid.UUID{
			uuid.MustParse("aaaa1111-aaaa-1111-aaaa-111111111111"),
			uuid.MustParse("aaaa2222-aaaa-2222-aaaa-222222222222"),
		},
	},
	{
		Name:          "search_work",
		Query:         "工作",
		ExpectedCount: 2,
		ExpectedIDs: []uuid.UUID{
			uuid.MustParse("88888888-8888-8888-8888-888888888888"),
			uuid.MustParse("99999999-9999-9999-9999-999999999999"),
		},
	},
	{
		Name:          "search_nonexistent",
		Query:         "不存在的內容xyz123",
		ExpectedCount: 0,
		ExpectedIDs:   []uuid.UUID{},
	},
}

SearchTestCases defines search test cases

Functions

func AssertEventually

func AssertEventually(t *testing.T, assertion func() bool, timeout time.Duration, msgAndArgs ...interface{})

AssertEventually asserts that condition eventually becomes true

func CosineSimilarity

func CosineSimilarity(a, b []float32) float32

CosineSimilarity calculates cosine similarity between two vectors

func Eventually

func Eventually(t *testing.T, condition func() bool, opts ...WaitOptions)

Eventually waits for condition to become true

func EventuallyWithContext

func EventuallyWithContext(ctx context.Context, t *testing.T, condition func(context.Context) bool, opts ...WaitOptions)

EventuallyWithContext waits for condition with context support

func IsCI

func IsCI() bool

IsCI checks if running in CI environment

func RequireDocker

func RequireDocker(t *testing.T)

RequireDocker requires Docker to be available

func RequireEventually

func RequireEventually(t *testing.T, assertion func() bool, timeout time.Duration, msgAndArgs ...interface{})

RequireEventually requires condition to eventually become true

func RequireIntegration

func RequireIntegration(t *testing.T)

RequireIntegration requires integration test environment

func Retry

func Retry(t *testing.T, operation func() error, opts ...RetryOptions) error

Retry executes operation until success or max attempts reached

func RetryUntilSuccess

func RetryUntilSuccess(t *testing.T, operation func() error, timeout time.Duration) error

RetryUntilSuccess keeps retrying until operation succeeds

func RetryWithContext

func RetryWithContext(ctx context.Context, t *testing.T, operation func(context.Context) error, opts ...RetryOptions) error

RetryWithContext performs retry with context support

func SkipIfShort

func SkipIfShort(t *testing.T)

SkipIfShort skips test in short mode

func SkipInCI

func SkipInCI(t *testing.T)

SkipInCI skips test in CI environment

func SkipWithoutDatabase

func SkipWithoutDatabase(t *testing.T)

SkipWithoutDatabase skips test when database is not available

func SkipWithoutDocker

func SkipWithoutDocker(t *testing.T)

SkipWithoutDocker skips test when Docker is not available

func WaitFor

func WaitFor(t *testing.T, name string, condition func() bool, timeout time.Duration)

WaitFor waits for specific condition with name

func WaitForError

func WaitForError(t *testing.T, operation func() error, timeout time.Duration) error

WaitForError waits for operation to return an error

func WaitForNoError

func WaitForNoError(t *testing.T, operation func() error, timeout time.Duration)

WaitForNoError waits for operation to succeed without error

func WaitForValue

func WaitForValue[T comparable](t *testing.T, getValue func() T, expected T, timeout time.Duration)

WaitForValue waits for function to return specific value

Types

type BenchmarkConfig

type BenchmarkConfig struct {
	CompareWith         string  `yaml:"compare_with"`
	RegressionThreshold float64 `yaml:"regression_threshold"`
}

BenchmarkConfig for benchmark settings

type ChaosConfig

type ChaosConfig struct {
	Enabled   bool            `yaml:"enabled"`
	Scenarios []ChaosScenario `yaml:"scenarios"`
}

ChaosConfig for chaos engineering settings

type ChaosScenario

type ChaosScenario struct {
	Name           string         `yaml:"name"`
	Description    string         `yaml:"description"`
	Probability    float64        `yaml:"probability"`
	Duration       string         `yaml:"duration,omitempty"`
	Latency        *LatencyConfig `yaml:"latency,omitempty"`
	SlowdownFactor int            `yaml:"slowdown_factor,omitempty"`
}

ChaosScenario for chaos scenarios

type ConcurrencyConfig

type ConcurrencyConfig struct {
	DefaultWorkers int    `yaml:"default_workers"`
	MaxWorkers     int    `yaml:"max_workers"`
	WorkerTimeout  string `yaml:"worker_timeout"`
}

ConcurrencyConfig for concurrency settings

type Config

type Config struct {
	Database     DatabaseConfig     `yaml:"database"`
	Test         TestConfig         `yaml:"test"`
	Scenarios    []ScenarioConfig   `yaml:"scenarios"`
	Chaos        ChaosConfig        `yaml:"chaos"`
	VectorSearch VectorSearchConfig `yaml:"vector_search"`
	Validation   ValidationConfig   `yaml:"validation"`
	Environments EnvironmentConfig  `yaml:"environments"`
	Reporting    ReportingConfig    `yaml:"reporting"`
}

Config defines test configuration structure

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default configuration

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads configuration file

func (*Config) GetEnvironmentSettings

func (c *Config) GetEnvironmentSettings() EnvSettings

GetEnvironmentSettings gets current environment settings

func (*Config) GetTimeout

func (c *Config) GetTimeout(name string) time.Duration

GetTimeout gets timeout settings

func (*Config) ParseDuration

func (c *Config) ParseDuration(s string) (time.Duration, error)

ParseDuration parses duration string

type CoverageConfig

type CoverageConfig struct {
	Target    int `yaml:"target"`
	FailUnder int `yaml:"fail_under"`
}

CoverageConfig for coverage settings

type DatabaseConfig

type DatabaseConfig struct {
	Image      string     `yaml:"image"`
	Name       string     `yaml:"name"`
	Username   string     `yaml:"username"`
	Password   string     `yaml:"password"`
	Port       int        `yaml:"port"`
	Pool       PoolConfig `yaml:"pool"`
	Migrations []string   `yaml:"migrations"`
}

DatabaseConfig for database settings

type Entity

type Entity struct {
	Name string
	Type string
}

Entity represents an entity for testing

type EnvSettings

type EnvSettings struct {
	UseTestcontainers bool   `yaml:"use_testcontainers"`
	ParallelTests     bool   `yaml:"parallel_tests"`
	VerboseLogging    bool   `yaml:"verbose_logging"`
	DatabaseURL       string `yaml:"database_url,omitempty"`
}

EnvSettings for environment configurations

type EnvironmentConfig

type EnvironmentConfig struct {
	Local   EnvSettings `yaml:"local"`
	CI      EnvSettings `yaml:"ci"`
	Staging EnvSettings `yaml:"staging"`
}

EnvironmentConfig for environment settings

type EventFixture

type EventFixture struct {
	StreamID  uuid.UUID
	Type      string
	Version   int
	Timestamp time.Time
	Data      map[string]interface{}
}

EventFixture defines test event data

type EventValidation

type EventValidation struct {
	MaxBatchSize int    `yaml:"max_batch_size"`
	MaxEventSize string `yaml:"max_event_size"`
}

EventValidation for event validation rules

type InvariantConfig

type InvariantConfig struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Enabled     bool   `yaml:"enabled"`
}

InvariantConfig for invariant settings

type LatencyConfig

type LatencyConfig struct {
	Min string `yaml:"min"`
	Max string `yaml:"max"`
}

LatencyConfig for latency settings

type MemoryFixture

type MemoryFixture struct {
	ID          uuid.UUID
	Content     string
	Type        string
	Tags        []string
	Entities    []Entity
	Confidence  float32
	Source      string
	Supersedes  []uuid.UUID
	CorrectedBy *uuid.UUID
}

MemoryFixture defines test memory data

type MemoryValidation

type MemoryValidation struct {
	MaxContentLength int `yaml:"max_content_length"`
	MinContentLength int `yaml:"min_content_length"`
	MaxTags          int `yaml:"max_tags"`
	MaxEntities      int `yaml:"max_entities"`
}

MemoryValidation for memory validation rules

type MockEmbedder

type MockEmbedder struct {

	// Control options for testing
	FailNext  bool          // Whether next call should fail
	Latency   time.Duration // Simulated latency
	CallCount int           // Call count statistics
	// contains filtered or unexported fields
}

MockEmbedder simulates embedding vector service

func NewMockEmbedder

func NewMockEmbedder() *MockEmbedder

NewMockEmbedder creates new mock embedder

func (*MockEmbedder) BatchEmbed

func (m *MockEmbedder) BatchEmbed(ctx context.Context, texts []string) ([][]float32, error)

BatchEmbed generates embeddings in batch

func (*MockEmbedder) Embed

func (m *MockEmbedder) Embed(ctx context.Context, text string) ([]float32, error)

Embed generates embedding vector for text

func (*MockEmbedder) GenerateDeterministicEmbedding

func (m *MockEmbedder) GenerateDeterministicEmbedding(text string) []float32

GenerateDeterministicEmbedding generates deterministic embedding for unknown text

func (*MockEmbedder) GetCallCount

func (m *MockEmbedder) GetCallCount() int

GetCallCount gets call count

func (*MockEmbedder) Reset

func (m *MockEmbedder) Reset()

Reset resets simulator state

func (*MockEmbedder) SetEmbedding

func (m *MockEmbedder) SetEmbedding(text string, embedding []float32)

SetEmbedding sets embedding vector for specific text (for testing)

func (*MockEmbedder) SimulateError

func (m *MockEmbedder) SimulateError()

SimulateError sets next call to fail

func (*MockEmbedder) SimulateLatency

func (m *MockEmbedder) SimulateLatency(d time.Duration)

SimulateLatency sets simulated latency

type PoolConfig

type PoolConfig struct {
	MaxConnections int    `yaml:"max_connections"`
	MinConnections int    `yaml:"min_connections"`
	MaxIdleTime    string `yaml:"max_idle_time"`
	MaxLifetime    string `yaml:"max_lifetime"`
}

PoolConfig for connection pool settings

type ReportingConfig

type ReportingConfig struct {
	Coverage   CoverageConfig  `yaml:"coverage"`
	Benchmarks BenchmarkConfig `yaml:"benchmarks"`
	Formats    []string        `yaml:"formats"`
	OutputDir  string          `yaml:"output_dir"`
	Artifacts  []string        `yaml:"artifacts"`
}

ReportingConfig for reporting settings

type RetryConfig

type RetryConfig struct {
	MaxAttempts  int    `yaml:"max_attempts"`
	InitialDelay string `yaml:"initial_delay"`
	MaxDelay     string `yaml:"max_delay"`
	Multiplier   int    `yaml:"multiplier"`
}

RetryConfig for retry settings

type RetryOptions

type RetryOptions struct {
	MaxAttempts  int
	InitialDelay time.Duration
	MaxDelay     time.Duration
	Multiplier   float64
	OnRetry      func(attempt int, err error) // Callback on each retry
}

RetryOptions defines retry configuration

func RetryOptionsFromConfig

func RetryOptionsFromConfig(config *Config) RetryOptions

RetryOptionsFromConfig creates retry options from test configuration

type ScenarioConfig

type ScenarioConfig struct {
	Name                string `yaml:"name"`
	Description         string `yaml:"description"`
	Workers             int    `yaml:"workers"`
	Duration            string `yaml:"duration"`
	OperationsPerWorker int    `yaml:"operations_per_worker"`
}

ScenarioConfig for test scenario settings

type SearchParamsConfig

type SearchParamsConfig struct {
	TopK                 []int     `yaml:"top_k"`
	SimilarityThresholds []float32 `yaml:"similarity_thresholds"`
}

SearchParamsConfig for search parameter settings

type Stopper

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

Stopper manages goroutine lifecycle (CockroachDB pattern)

func NewStopper

func NewStopper() *Stopper

NewStopper creates a new Stopper

func (*Stopper) RunAsync

func (s *Stopper) RunAsync(fn func(context.Context))

RunAsync runs a task asynchronously

func (*Stopper) ShouldQuiesce

func (s *Stopper) ShouldQuiesce() <-chan struct{}

ShouldQuiesce returns a channel that is closed when the stopper begins quiescing

func (*Stopper) Stop

func (s *Stopper) Stop()

Stop stops all async tasks

type TestCluster

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

TestCluster represents a test cluster inspired by CockroachDB's testing patterns It provides isolated database instances and lifecycle management

func NewTestCluster

func NewTestCluster(t *testing.T) *TestCluster

NewTestCluster creates a new test cluster Following CockroachDB pattern of test isolation

func (*TestCluster) AddDatabase

func (tc *TestCluster) AddDatabase(opts ...TestDatabaseOption) *TestDatabase

AddDatabase adds a new database to the cluster

func (*TestCluster) GetDatabase

func (tc *TestCluster) GetDatabase(index int) *TestDatabase

GetDatabase returns a database by index

func (*TestCluster) PrimaryDB

func (tc *TestCluster) PrimaryDB() *TestDatabase

PrimaryDB returns the first database (convenience method)

func (*TestCluster) RunAsync

func (tc *TestCluster) RunAsync(fn func(context.Context))

RunAsync runs a function asynchronously with proper lifecycle management Inspired by CockroachDB's stopper.RunAsyncTask

func (*TestCluster) Stop

func (tc *TestCluster) Stop()

Stop gracefully stops the test cluster

type TestConfig

type TestConfig struct {
	Timeouts    TimeoutConfig     `yaml:"timeouts"`
	Retry       RetryConfig       `yaml:"retry"`
	Concurrency ConcurrencyConfig `yaml:"concurrency"`
}

TestConfig for test execution settings

type TestDatabase

type TestDatabase struct {
	Container testcontainers.Container
	Pool      *pgxpool.Pool
	DB        *sql.DB
	DSN       string
	Host      string
	Port      string
}

TestDatabase represents an isolated test database instance

func NewTestDatabase

func NewTestDatabase(t *testing.T, opts ...TestDatabaseOption) *TestDatabase

NewTestDatabase creates an isolated PostgreSQL test database with pgvector Following testcontainers best practices: 1. Dynamic port mapping 2. Proper wait strategies 3. Automatic cleanup via t.Cleanup()

func (*TestDatabase) MustExec

func (db *TestDatabase) MustExec(t *testing.T, query string, args ...interface{})

MustExec executes a query and fails the test on error

func (*TestDatabase) RunMigrations

func (db *TestDatabase) RunMigrations(t *testing.T, migrationPath string)

RunMigrations executes database migrations

func (*TestDatabase) TruncateTables

func (db *TestDatabase) TruncateTables(t *testing.T, tables ...string)

TruncateTables clears all data from specified tables Useful for test isolation within the same database

type TestDatabaseOption

type TestDatabaseOption func(*testDatabaseConfig)

TestDatabaseOption configures test database creation

func WithImage

func WithImage(image string) TestDatabaseOption

WithImage sets custom Docker image

func WithInitScripts

func WithInitScripts(scripts ...string) TestDatabaseOption

WithInitScripts adds SQL initialization scripts

func WithPoolSize

func WithPoolSize(min, max int32) TestDatabaseOption

WithPoolSize configures connection pool size

func WithStartupTimeout

func WithStartupTimeout(timeout time.Duration) TestDatabaseOption

WithStartupTimeout sets container startup timeout

type TestFixture

type TestFixture struct {
	T       *testing.T
	Cluster *TestCluster
	DB      *TestDatabase
	Pool    *pgxpool.Pool

	// Hooks for custom setup/teardown
	BeforeEach func(*testing.T)
	AfterEach  func(*testing.T)
}

TestFixture provides test isolation and setup/teardown Inspired by CockroachDB's serverutils.TestServerInterface

func NewTestFixture

func NewTestFixture(t *testing.T) *TestFixture

NewTestFixture creates a new test fixture with isolated database

func (*TestFixture) MustExec

func (f *TestFixture) MustExec(query string, args ...interface{})

MustExec executes a query and fails the test on error

func (*TestFixture) Run

func (f *TestFixture) Run(name string, fn func(*TestFixture))

Run executes a test with proper setup/teardown Similar to testify/suite but simpler

func (*TestFixture) RunParallel

func (f *TestFixture) RunParallel(name string, fn func(*TestFixture))

RunParallel executes a test in parallel

func (*TestFixture) TruncateAll

func (f *TestFixture) TruncateAll()

TruncateAll truncates all test tables

type TimeoutConfig

type TimeoutConfig struct {
	ContainerStartup string `yaml:"container_startup"`
	OperationDefault string `yaml:"operation_default"`
	AsyncWait        string `yaml:"async_wait"`
	Shutdown         string `yaml:"shutdown"`
}

TimeoutConfig for timeout settings

type ValidationConfig

type ValidationConfig struct {
	Memory     MemoryValidation  `yaml:"memory"`
	Event      EventValidation   `yaml:"event"`
	Invariants []InvariantConfig `yaml:"invariants"`
}

ValidationConfig for validation settings

type VectorSearchConfig

type VectorSearchConfig struct {
	DatasetSizes       map[string]int     `yaml:"dataset_sizes"`
	SearchParams       SearchParamsConfig `yaml:"search_params"`
	PerformanceTargets map[string]string  `yaml:"performance_targets"`
}

VectorSearchConfig for vector search settings

type WaitOptions

type WaitOptions struct {
	Timeout  time.Duration
	Interval time.Duration
	Message  string
}

WaitOptions defines wait configuration

Jump to

Keyboard shortcuts

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