testing

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

pi: harness/session/testing/conformance/session-repo.ts — SessionRepo conformance case groups (lifecycle, ownership, messages, forks, fork coordination).

pi: harness/session/testing/conformance/storage.ts — runner-independent conformance cases for the durable Storage contract.

Assertion mapping: node:assert deepStrictEqual → JSON-normalized reflect.DeepEqual (session values contain slices and are not comparable with ==); rejects → expecting a non-nil error.

pi: harness/session/testing/gating-storage.ts — test-only storage decorator that deterministically parks admitted commits.

pi: harness/session/testing/instrumented-storage.ts — test-only transparent Storage decorator that records commit admission.

pi: harness/session/testing/storage-decorator.ts — test-only forwarding base for decorators that alter one part of Storage behavior.

pi: harness/session/testing/types.ts — conformance infrastructure types.

pi ships session/testing in src; pig keeps it as a regular package under agent/harness/session/testing, consumed by test files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertJSONEqual

func AssertJSONEqual(t *testing.T, name string, got, want any)

assertJSONEqual compares two values via JSON normalization (pi: deepStrictEqual on JSON-shaped data).

func RunConformanceCases

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

RunConformanceCases executes the cases as subtests, grouped by Group.

Types

type CommitDiscarded

type CommitDiscarded struct{ Message string }

CommitDiscarded is thrown for every commit rejected after simulated storage loss (pi: CommitDiscarded).

func (*CommitDiscarded) Error

func (e *CommitDiscarded) Error() string

type ConformanceCase

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

ConformanceCase is a runner-independent conformance case (pi: ConformanceCase); the async run collapses to a func taking *testing.T.

func SessionRepoConformanceCases

func SessionRepoConformanceCases[TMetadata any](factory RepoFactory[TMetadata]) []ConformanceCase

SessionRepoConformanceCases creates every SessionRepo conformance case (pi: createSessionRepoConformance).

func SessionRepoForkAncestryConformance

func SessionRepoForkAncestryConformance[TMetadata any](factory RepoFactory[TMetadata]) []ConformanceCase

SessionRepoForkAncestryConformance creates ancestry placement cases (pi: "enforces branch ancestry for at and before placement").

func SessionRepoForkBehaviorConformance

func SessionRepoForkBehaviorConformance[TMetadata any](factory RepoFactory[TMetadata]) []ConformanceCase

SessionRepoForkBehaviorConformance creates fork-content cases (pi: createSessionRepoForkBehaviorConformance).

func SessionRepoForkConformance

func SessionRepoForkConformance[TMetadata any](factory RepoFactory[TMetadata]) []ConformanceCase

SessionRepoForkConformance creates every fork conformance case (pi: createSessionRepoForkConformance).

func SessionRepoForkCoordinationConformance

func SessionRepoForkCoordinationConformance[TMetadata any](factory RepoFactory[TMetadata]) []ConformanceCase

SessionRepoForkCoordinationConformance creates every fork coordination case (pi: createSessionRepoForkCoordinationConformance).

func SessionRepoLifecycleConformance

func SessionRepoLifecycleConformance[TMetadata any](factory RepoFactory[TMetadata]) []ConformanceCase

SessionRepoLifecycleConformance creates lifecycle cases (pi: createSessionRepoLifecycleConformance).

func SessionRepoMessageConformance

func SessionRepoMessageConformance[TMetadata any](factory RepoFactory[TMetadata]) []ConformanceCase

SessionRepoMessageConformance creates message cases (pi: createSessionRepoMessageConformance).

func SessionRepoOwnershipConformance

func SessionRepoOwnershipConformance[TMetadata any](factory RepoFactory[TMetadata]) []ConformanceCase

SessionRepoOwnershipConformance creates exclusive-open cases (pi: createSessionRepoOwnershipConformance).

func StorageConformanceCases

func StorageConformanceCases(factory func(t *testing.T) StorageFixture) []ConformanceCase

StorageConformanceCases creates fresh, runner-independent cases for the durable Storage contract (pi: createStorageConformance).

type ConformanceRepo

type ConformanceRepo[TMetadata any] interface {
	// Metadata reads the concrete metadata off a session handle.
	Metadata(sess session.Session) TMetadata
	// MetadataID returns the session id of one metadata value.
	MetadataID(metadata TMetadata) string
	// MetadataParentSessionID returns the optional parent link.
	MetadataParentSessionID(metadata TMetadata) *string
	// Create builds the backend's create options from the common fields.
	Create(id *string, parentSessionID *string, ctx context.Context) (session.Session, error)
	Open(metadata TMetadata, ctx context.Context) (session.Session, error)
	List(ctx context.Context) ([]TMetadata, error)
	Delete(metadata TMetadata, ctx context.Context) error
	Fork(source TMetadata, options session.ForkOptions, ctx context.Context) (session.Session, error)
	Close(ctx context.Context) error
}

ConformanceRepo is the per-backend adapter over SessionRepo[TMetadata, TCreate, TList] that the conformance cases drive (pi: the factory returns Pick<SessionRepo<TMetadata>, "create" | "open" | "list" | "delete"> and each backend wrapper adapts its concrete option/metadata shapes; the metadata accessors stand in for pi's typed `session.metadata` reads).

type GatingStorage

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

GatingStorage parks admitted commits until released (pi: GatingStorage).

func NewGatingStorage

func NewGatingStorage(delegate session.Storage) *GatingStorage

NewGatingStorage wraps one delegate.

func (*GatingStorage) Arm

func (s *GatingStorage) Arm()

Arm lets fixture setup bypass gating until explicitly armed (pi: arm).

func (*GatingStorage) Commit

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

func (*GatingStorage) Discard

func (s *GatingStorage) Discard()

Discard drops parked commits and permanently rejects every later commit (pi: discard).

func (*GatingStorage) Next

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

Next releases count commits in FIFO order and waits until each write lands (pi: next).

func (*GatingStorage) Pending

func (s *GatingStorage) Pending() int

Pending reports the number of parked commits (pi: pending).

func (*GatingStorage) WaitPending

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

WaitPending waits until at least count commits are parked (pi: waitPending).

type InstrumentedStorage

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

InstrumentedStorage records every Commit admission (pi: InstrumentedStorage).

func NewInstrumentedStorage

func NewInstrumentedStorage(delegate session.Storage) *InstrumentedStorage

NewInstrumentedStorage wraps one delegate.

func (*InstrumentedStorage) ClearCommitAttempts

func (s *InstrumentedStorage) ClearCommitAttempts()

ClearCommitAttempts resets the recording (pi: clearCommitAttempts).

func (*InstrumentedStorage) Commit

func (*InstrumentedStorage) GetCommitAttempts

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

GetCommitAttempts returns a copy of the recorded attempts (pi: getCommitAttempts).

type RepoFactory

type RepoFactory[TMetadata any] func(t *testing.T) ConformanceRepo[TMetadata]

RepoFactory creates a fresh repo per case (pi's backendFactory).

type StorageDecorator

type StorageDecorator struct {
	Delegate session.Storage
}

StorageDecorator forwards every Storage call to its delegate (pi: StorageDecorator).

func (*StorageDecorator) Close

func (d *StorageDecorator) Close(ctx context.Context) error

func (*StorageDecorator) Commit

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

func (*StorageDecorator) GetEntries

func (d *StorageDecorator) GetEntries(ids []string, ctx context.Context) (map[string]session.Entry, error)

func (*StorageDecorator) GetStats

func (*StorageDecorator) GetValue

func (d *StorageDecorator) GetValue(address session.Value, ctx context.Context) (*session.StoredValue, error)

func (*StorageDecorator) ReadList

func (*StorageDecorator) ScanBranch

func (*StorageDecorator) ScanBranchStructure

func (d *StorageDecorator) ScanBranchStructure(query session.StorageBranchScan, ctx context.Context) ([]session.EntryStructure, error)

func (*StorageDecorator) ScanEntries

func (d *StorageDecorator) ScanEntries(query session.EntryScan, ctx context.Context) ([]session.Entry, error)

func (*StorageDecorator) ScanUsage

func (d *StorageDecorator) ScanUsage(query session.UsageScan, ctx context.Context) ([]session.UsageRow, error)

func (*StorageDecorator) ScanValues

func (d *StorageDecorator) ScanValues(prefix session.Value, ctx context.Context) ([]session.StoredValue, error)

type StorageFixture

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

StorageFixture is a fresh backend storage instance owned by one test or benchmark case (pi: StorageFixture; the AsyncDisposable collapse is the case runner's cleanup).

Jump to

Keyboard shortcuts

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