projections

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package projections provides testing utilities for projection development. It includes fixtures for testing inline, async, and live projections with event application and read model verification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncProjectionFixture

type AsyncProjectionFixture[T any] struct {
	*ProjectionTestFixture[T]
	// contains filtered or unexported fields
}

AsyncProjectionFixture provides specialized testing for async projections.

func TestAsyncProjection

func TestAsyncProjection[T any](t TB, projection mink.AsyncProjection) *AsyncProjectionFixture[T]

TestAsyncProjection creates a fixture for testing async projections.

func (*AsyncProjectionFixture[T]) ProcessBatch

func (f *AsyncProjectionFixture[T]) ProcessBatch(events []mink.StoredEvent) error

ProcessBatch processes a batch of events.

func (*AsyncProjectionFixture[T]) WithRepository

func (f *AsyncProjectionFixture[T]) WithRepository(repo mink.ReadModelRepository[T]) *AsyncProjectionFixture[T]

WithRepository sets a custom repository for the async fixture.

type EngineTestFixture

type EngineTestFixture struct {
	// contains filtered or unexported fields
}

EngineTestFixture provides testing utilities for the projection engine.

func TestEngine

func TestEngine(t TB) *EngineTestFixture

TestEngine creates a new engine test fixture.

func (*EngineTestFixture) AppendEvents

func (f *EngineTestFixture) AppendEvents(streamID string, events ...interface{}) *EngineTestFixture

AppendEvents appends events to the store.

func (*EngineTestFixture) Engine

Engine returns the underlying engine.

func (*EngineTestFixture) RegisterAsync

func (f *EngineTestFixture) RegisterAsync(projection mink.AsyncProjection, opts mink.AsyncOptions) *EngineTestFixture

RegisterAsync registers an async projection.

func (*EngineTestFixture) RegisterInline

func (f *EngineTestFixture) RegisterInline(projection mink.InlineProjection) *EngineTestFixture

RegisterInline registers an inline projection.

func (*EngineTestFixture) RegisterLive

func (f *EngineTestFixture) RegisterLive(projection mink.LiveProjection, opts ...mink.LiveOptions) *EngineTestFixture

RegisterLive registers a live projection.

func (*EngineTestFixture) Start

Start starts the projection engine.

func (*EngineTestFixture) Stop

Stop stops the projection engine.

func (*EngineTestFixture) Store

func (f *EngineTestFixture) Store() *mink.EventStore

Store returns the underlying event store.

func (*EngineTestFixture) WaitForProjection

func (f *EngineTestFixture) WaitForProjection(name string, timeout time.Duration) *EngineTestFixture

WaitForProjection waits for a projection to catch up.

func (*EngineTestFixture) WithContext

func (f *EngineTestFixture) WithContext(ctx context.Context) *EngineTestFixture

WithContext sets a custom context.

type InlineProjectionFixture

type InlineProjectionFixture[T any] struct {
	*ProjectionTestFixture[T]
	// contains filtered or unexported fields
}

InlineProjectionFixture provides specialized testing for inline projections.

func TestInlineProjection

func TestInlineProjection[T any](t TB, projection mink.InlineProjection) *InlineProjectionFixture[T]

TestInlineProjection creates a fixture for testing inline projections.

func (*InlineProjectionFixture[T]) ApplyEvent

func (f *InlineProjectionFixture[T]) ApplyEvent(event mink.StoredEvent) error

ApplyEvent applies a single event to the inline projection.

func (*InlineProjectionFixture[T]) WithRepository

func (f *InlineProjectionFixture[T]) WithRepository(repo mink.ReadModelRepository[T]) *InlineProjectionFixture[T]

WithRepository sets a custom repository for the inline fixture.

type LiveProjectionFixture

type LiveProjectionFixture[T any] struct {
	*ProjectionTestFixture[T]
	// contains filtered or unexported fields
}

LiveProjectionFixture provides specialized testing for live projections.

func TestLiveProjection

func TestLiveProjection[T any](t TB, projection mink.LiveProjection) *LiveProjectionFixture[T]

TestLiveProjection creates a fixture for testing live projections.

func (*LiveProjectionFixture[T]) OnEvent

func (f *LiveProjectionFixture[T]) OnEvent(event mink.StoredEvent)

OnEvent calls OnEvent on the live projection.

func (*LiveProjectionFixture[T]) ThenIsTransient

func (f *LiveProjectionFixture[T]) ThenIsTransient(expected bool)

ThenIsTransient asserts the projection is transient.

func (*LiveProjectionFixture[T]) WithRepository

func (f *LiveProjectionFixture[T]) WithRepository(repo mink.ReadModelRepository[T]) *LiveProjectionFixture[T]

WithRepository sets a custom repository for the live fixture.

type ProjectionTestFixture

type ProjectionTestFixture[T any] struct {
	// contains filtered or unexported fields
}

ProjectionTestFixture provides testing utilities for projections.

func TestProjection

func TestProjection[T any](t TB, projection mink.Projection) *ProjectionTestFixture[T]

TestProjection creates a new projection test fixture.

func (*ProjectionTestFixture[T]) Events

func (f *ProjectionTestFixture[T]) Events() []mink.StoredEvent

Events returns the applied events.

func (*ProjectionTestFixture[T]) GivenDomainEvents

func (f *ProjectionTestFixture[T]) GivenDomainEvents(streamID string, domainEvents ...interface{}) *ProjectionTestFixture[T]

GivenDomainEvents creates stored events from domain events.

func (*ProjectionTestFixture[T]) GivenEvents

func (f *ProjectionTestFixture[T]) GivenEvents(events ...mink.StoredEvent) *ProjectionTestFixture[T]

GivenEvents applies events to the projection.

func (*ProjectionTestFixture[T]) Repository

func (f *ProjectionTestFixture[T]) Repository() mink.ReadModelRepository[T]

Repository returns the underlying repository for additional assertions.

func (*ProjectionTestFixture[T]) ThenReadModel

func (f *ProjectionTestFixture[T]) ThenReadModel(id string, expected T)

ThenReadModel asserts the read model matches the expected state.

func (*ProjectionTestFixture[T]) ThenReadModelCount

func (f *ProjectionTestFixture[T]) ThenReadModelCount(expected int)

ThenReadModelCount asserts the number of read models.

func (*ProjectionTestFixture[T]) ThenReadModelExists

func (f *ProjectionTestFixture[T]) ThenReadModelExists(id string) *T

ThenReadModelExists asserts that a read model exists.

func (*ProjectionTestFixture[T]) ThenReadModelMatches

func (f *ProjectionTestFixture[T]) ThenReadModelMatches(id string, check func(t TB, model *T))

ThenReadModelMatches asserts the read model passes a custom check.

func (*ProjectionTestFixture[T]) ThenReadModelNotExists

func (f *ProjectionTestFixture[T]) ThenReadModelNotExists(id string)

ThenReadModelNotExists asserts that a read model does not exist.

func (*ProjectionTestFixture[T]) WithContext

func (f *ProjectionTestFixture[T]) WithContext(ctx context.Context) *ProjectionTestFixture[T]

WithContext sets a custom context.

func (*ProjectionTestFixture[T]) WithRepository

func (f *ProjectionTestFixture[T]) WithRepository(repo mink.ReadModelRepository[T]) *ProjectionTestFixture[T]

WithRepository sets a custom repository.

type TB

type TB = testing.TB

TB is an alias for testing.TB to enable easier mocking in tests.

Jump to

Keyboard shortcuts

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