reactortest

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: 17 Imported by: 0

Documentation

Overview

Package reactortest is the contract suite that every Reactor backend (Pg and in-memory consumer Runtimes) must pass. A test calls

reactortest.Run(t, func(t *testing.T, codec *eventstore.Codec) reactortest.Backend { ... })

and the suite exercises the Reactor only through its public API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, newBackend func(t *testing.T, codec *eventstore.Codec) Backend, opts ...Option)

Run runs the contract suite. newBackend is called once per case with the codec the Store must encode with.

Types

type Backend

type Backend struct {
	// Store and UnitOfWork write events; Store encodes with the suite's
	// codec.
	Store      eventstore.Store
	UnitOfWork eventstore.UnitOfWork
	Runtime    consumer.Runtime
	// Redeliver hands env to r's live handler once more, as after a crash
	// between handling an event and advancing the Cursor.
	Redeliver func(ctx context.Context, r *reactor.Reactor, env eventstore.Envelope) error
	// Discarded lists the audit records Discard kept for r, in the order
	// they were discarded.
	Discarded func(ctx context.Context, r *reactor.Reactor) ([]Discarded, error)
}

Backend is one empty event log with a consumer Runtime over it.

type Discarded

type Discarded struct {
	EventID uuid.UUID
	By      string
}

Discarded is the audit record of a discarded event.

type Option

type Option func(*config)

Option configures Run.

func InBubble

func InBubble() Option

InBubble runs every case inside a testing/synctest bubble, so retries and timeouts use fake time. For in-memory backends.

func Sequential

func Sequential() Option

Sequential runs the cases one after another, for Pg backends whose databases share one cluster (pg_snapshot_xmin is cluster-wide).

Jump to

Keyboard shortcuts

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