sessiontesting

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sessiontesting holds runner-independent session test fixtures and storage decorators shared by every backend's conformance and benchmarks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunConformance

func RunConformance(t *testing.T, cases []ConformanceCase)

RunConformance registers every case as a subtest grouped by Group.

Types

type CommitDiscarded

type CommitDiscarded struct{ Message string }

CommitDiscarded rejects every commit after simulated storage loss.

func (*CommitDiscarded) Error

func (err *CommitDiscarded) Error() string

type ConformanceCase

type ConformanceCase struct {
	Group string
	Name  string
	Run   func(t *testing.T)
}

ConformanceCase is a runner-independent conformance case; register each with t.Run(testCase.Group+"/"+testCase.Name, testCase.Run).

type GatingStorage

type GatingStorage struct {
	StorageDecorator
	// contains filtered or unexported fields
}

GatingStorage is a test-only decorator that deterministically parks admitted commits once armed.

func NewGatingStorage

func NewGatingStorage(delegate session.Storage) *GatingStorage

NewGatingStorage wraps delegate; setup commits bypass gating until Arm.

func (*GatingStorage) Arm

func (storage *GatingStorage) Arm()

Arm starts parking commits.

func (*GatingStorage) Commit

func (storage *GatingStorage) Commit(ctx context.Context, writes []session.Write) (session.CommitResult, error)

Commit parks an armed commit until Next releases it, then delegates.

func (*GatingStorage) Discard

func (storage *GatingStorage) Discard()

Discard drops parked commits and permanently rejects every later commit.

func (*GatingStorage) Next

func (storage *GatingStorage) Next(count int) error

Next releases count commits in FIFO order, returning after each lands.

func (*GatingStorage) Pending

func (storage *GatingStorage) Pending() int

Pending reports the number of parked commits.

func (*GatingStorage) WaitPending

func (storage *GatingStorage) WaitPending(count int) error

WaitPending blocks until at least count commits are parked.

type InstrumentedStorage

type InstrumentedStorage struct {
	StorageDecorator
	// contains filtered or unexported fields
}

InstrumentedStorage is a test-only transparent Storage decorator that records commit admission before delegating.

func NewInstrumentedStorage

func NewInstrumentedStorage(delegate session.Storage) *InstrumentedStorage

NewInstrumentedStorage wraps delegate.

func (*InstrumentedStorage) ClearCommitAttempts

func (storage *InstrumentedStorage) ClearCommitAttempts()

ClearCommitAttempts forgets recorded transactions without touching the delegate.

func (*InstrumentedStorage) Commit

func (storage *InstrumentedStorage) Commit(ctx context.Context, writes []session.Write) (session.CommitResult, error)

Commit records the transaction, then delegates.

func (*InstrumentedStorage) GetCommitAttempts

func (storage *InstrumentedStorage) GetCommitAttempts() [][]session.Write

GetCommitAttempts returns the recorded transactions in admission order.

type StorageDecorator

type StorageDecorator struct {
	session.Storage
}

StorageDecorator is a test-only forwarding base for decorators that alter one part of Storage behavior; embedded methods forward to the delegate.

func NewStorageDecorator

func NewStorageDecorator(delegate session.Storage) StorageDecorator

NewStorageDecorator wraps delegate.

type StorageFixture

type StorageFixture struct {
	Storage session.Storage
	Close   func() error
}

StorageFixture is a fresh backend storage instance owned by one test or benchmark case.

Directories

Path Synopsis
Package benchmark holds the deterministic session workloads shared by every backend's storage and repository benchmarks.
Package benchmark holds the deterministic session workloads shared by every backend's storage and repository benchmarks.
Package conformance holds the runner-independent Storage and SessionRepo conformance suites every session backend must pass.
Package conformance holds the runner-independent Storage and SessionRepo conformance suites every session backend must pass.

Jump to

Keyboard shortcuts

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