bdd

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package bdd provides BDD-style test fixtures for event-sourced aggregates. It enables expressive Given-When-Then testing patterns for command handling and aggregate behavior verification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandTestFixture

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

CommandTestFixture provides BDD-style testing with command bus integration.

func GivenCommand

func GivenCommand(t TB, bus *mink.CommandBus, store *mink.EventStore) *CommandTestFixture

GivenCommand creates a new command test fixture with a command bus.

func (*CommandTestFixture) ThenFails

func (f *CommandTestFixture) ThenFails(expectedErr error)

ThenFails asserts the command failed with the expected error.

func (*CommandTestFixture) ThenReturnsAggregateID

func (f *CommandTestFixture) ThenReturnsAggregateID(expected string) *CommandTestFixture

ThenReturnsAggregateID asserts the result contains the expected aggregate ID.

func (*CommandTestFixture) ThenReturnsVersion

func (f *CommandTestFixture) ThenReturnsVersion(expected int64) *CommandTestFixture

ThenReturnsVersion asserts the result contains the expected version.

func (*CommandTestFixture) ThenSucceeds

func (f *CommandTestFixture) ThenSucceeds() *CommandTestFixture

ThenSucceeds asserts the command succeeded.

func (*CommandTestFixture) When

When dispatches the command.

func (*CommandTestFixture) WithContext

WithContext sets a custom context for the command execution.

func (*CommandTestFixture) WithExistingEvents

func (f *CommandTestFixture) WithExistingEvents(streamID string, events ...interface{}) *CommandTestFixture

WithExistingEvents sets up initial events in the event store.

type TB

type TB = testing.TB

TB is an alias for testing.TB interface to allow mocking in tests

type TestFixture

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

TestFixture provides BDD-style testing for aggregates.

func Given

func Given(t TB, aggregate mink.Aggregate, events ...interface{}) *TestFixture

Given sets up the initial aggregate with optional historical events. This establishes the "Given" state before executing a command.

func (*TestFixture) Then

func (f *TestFixture) Then(expectedEvents ...interface{})

Then asserts that the aggregate produced the expected events.

func (*TestFixture) ThenError

func (f *TestFixture) ThenError(expectedErr error)

ThenError asserts that the command produced the expected error.

func (*TestFixture) ThenErrorContains

func (f *TestFixture) ThenErrorContains(substring string)

ThenErrorContains asserts that the error message contains a substring.

func (*TestFixture) ThenNoEvents

func (f *TestFixture) ThenNoEvents()

ThenNoEvents asserts that no events were produced.

func (*TestFixture) When

func (f *TestFixture) When(commandFunc func() error) *TestFixture

When executes a command function against the aggregate. The command function should call methods on the aggregate and return any error.

Jump to

Keyboard shortcuts

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