Documentation
¶
Overview ¶
Package consumertest is the contract suite that every consumer Runtime (Pg and in-memory) must pass. A runtime test calls
consumertest.Run(t, func(t *testing.T, codec *eventstore.Codec) consumertest.Backend { ... })
and the suite exercises it only through the public consumer API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
Effects Effects
// Restart returns a new Runtime over the same log and Cursors, as after
// a process restart. Runtimes it returned earlier are no longer used.
Restart func(t *testing.T) consumer.Runtime
}
Backend is one empty event log with a Runtime over it.
type Effects ¶
type Effects interface {
Record(ctx context.Context, key string) error
// Keys returns the committed keys in record order.
Keys(ctx context.Context) ([]string, error)
}
Effects is a read model a handler writes to. Record joins the Cursor transaction in ctx, so a rolled-back transaction drops its records.
type InMemoryEffects ¶
type InMemoryEffects struct {
// contains filtered or unexported fields
}
InMemoryEffects is Effects for in-memory backends; Record stages its write with postgres.Stage.
type Option ¶
type Option func(*config)
Option configures Run.
func InBubble ¶
func InBubble() Option
InBubble runs every case and its newBackend inside a testing/synctest bubble, so retries and Age 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, so a transaction of a parallel case would hide fresh events from Drain.
type PgEffects ¶
type PgEffects struct {
// contains filtered or unexported fields
}
PgEffects is Effects for Pg backends. Record inserts through postgres.Conn, so it joins the Cursor transaction in ctx.
func NewPgEffects ¶
NewPgEffects creates the effects table in pool's database.