eventstoretest

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package eventstoretest is the write-side contract suite that every eventstore backend (Pg and in-memory) must pass. A backend test calls

eventstoretest.Run(t, func(t *testing.T) eventstoretest.Backend { ... })

and the suite exercises it only through eventstore.Repository and eventstore.UnitOfWork.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, newBackend func(t *testing.T) Backend)

Run runs the contract suite. newBackend is called once per subtest.

Types

type Backend

type Backend struct {
	// Store opens a Store over the Backend's log. Stores opened from one
	// Backend share their events, whatever their Codec.
	Store      func(cfg StoreConfig) eventstore.Store
	UnitOfWork eventstore.UnitOfWork
	// Guard and Numbering must join the UnitOfWork's transactions.
	Guard     Guard
	Numbering Numbering
	// Outer runs fn in a plain transaction of the UnitOfWork's backend
	// (postgres.PgUnitOfWork or postgres.InMemoryUnitOfWork), which Command
	// transactions in fn join.
	Outer func(ctx context.Context, fn func(ctx context.Context) error) error
}

Backend is one empty event log under test.

type Guard

type Guard interface {
	Claim(ctx context.Context, key guard.Key) error
}

Guard is the claim surface of guard.PgStore and guard.InMemoryStore.

type Numbering

type Numbering interface {
	Next(ctx context.Context, seq numbering.Sequence) (int64, error)
}

Numbering is the surface of numbering.PgStore and numbering.InMemoryStore.

type StoreConfig

type StoreConfig struct {
	Codec *eventstore.Codec
	// Clock is passed to eventstore.WithClock.
	Clock func() time.Time
}

StoreConfig configures one Store opened by a Backend.

Jump to

Keyboard shortcuts

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