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 ¶
- type CommandTestFixture
- func (f *CommandTestFixture) ThenFails(expectedErr error)
- func (f *CommandTestFixture) ThenReturnsAggregateID(expected string) *CommandTestFixture
- func (f *CommandTestFixture) ThenReturnsVersion(expected int64) *CommandTestFixture
- func (f *CommandTestFixture) ThenSucceeds() *CommandTestFixture
- func (f *CommandTestFixture) When(cmd mink.Command) *CommandTestFixture
- func (f *CommandTestFixture) WithContext(ctx context.Context) *CommandTestFixture
- func (f *CommandTestFixture) WithExistingEvents(streamID string, events ...interface{}) *CommandTestFixture
- type TB
- type TestFixture
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 ¶
func (f *CommandTestFixture) When(cmd mink.Command) *CommandTestFixture
When dispatches the command.
func (*CommandTestFixture) WithContext ¶
func (f *CommandTestFixture) WithContext(ctx context.Context) *CommandTestFixture
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 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.