mocks

package module
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 6 Imported by: 0

README

eventsourced mocks

GoReportCard GoDoc Build Statuscoverage report

Package mocks provides mock implementations of the event store which can be used to unit test applications using the eventsourced framework.

Download:

go get gitlab.com/unboundsoftware/eventsourced/mocks

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventModifier added in v0.6.2

type EventModifier func(event eventsourced.Event)

type Publisher added in v0.0.2

type Publisher struct {
	PublishFunc func(event eventsourced.Event) error
	// contains filtered or unexported fields
}

Publisher is a mock implementation of eventsourced.EventPublisher

func (*Publisher) AssertPublished added in v0.0.2

func (p *Publisher) AssertPublished(t testing.TB, want []eventsourced.Event, modifiers ...EventModifier)

AssertPublished checks that the expected events were published

func (*Publisher) Publish added in v0.0.2

func (p *Publisher) Publish(_ context.Context, event eventsourced.Event) error

Publish mocks eventsourced.EventPublisher.Publish by calling PublishFunc or by adding the published event to the events-slice if PublishFunc is nil

type Store

type Store struct {
	RestoreSnapshotFunc func(aggregate eventsourced.Aggregate) (eventsourced.Snapshot, error)
	StoreSnapshotFunc   func(aggregate eventsourced.Aggregate, sequenceNo int) error
	GetEventsFunc       func(aggregate eventsourced.Aggregate, sinceSnapshot eventsourced.Snapshot) ([]eventsourced.EventWrapper, error)
	StoreEventFunc      func(
		aggregate eventsourced.Aggregate,
		event eventsourced.Event,
		sequenceNo int,
		newAggregate bool,
	) error
	GetAggregateRootsFunc func(aggregateType reflect.Type) ([]eventsourced.ID, error)
	EventsFunc            func(fromID int, c chan eventsourced.Event, aggregateTypes ...eventsourced.Aggregate) error
	MaxGlobalSeqNoFunc    func(ctx context.Context) (int, error)
}

Store is a mock implementation of eventsourced.EventStore

func (*Store) Events added in v0.0.5

func (m *Store) Events(_ context.Context, fromID int, c chan eventsourced.Event, aggregateTypes ...eventsourced.Aggregate) error

Events mocks eventsourced.EventStore.Events by calling EventsFunc or by returning nil if EventsFunc is nil

func (*Store) GetAggregateRoots

func (m *Store) GetAggregateRoots(_ context.Context, aggregateType reflect.Type) ([]eventsourced.ID, error)

GetAggregateRoots mocks eventsourced.EventStore.GetAggregateRoots by calling GetAggregateRootsFunc or by returning nil, nil if GetAggregateRootsFunc is nil

func (*Store) GetEvents

func (m *Store) GetEvents(_ context.Context, aggregate eventsourced.Aggregate, sinceSnapshot eventsourced.Snapshot) ([]eventsourced.EventWrapper, error)

GetEvents mocks eventsourced.EventStore.GetEvents by calling GetEventsFunc or by returning nil, nil if GetEventsFunc is nil

func (*Store) MaxGlobalSequenceNo added in v0.6.0

func (m *Store) MaxGlobalSequenceNo(ctx context.Context) (int, error)

func (*Store) RestoreSnapshot added in v0.5.0

func (m *Store) RestoreSnapshot(_ context.Context, aggregate eventsourced.Aggregate) (eventsourced.Snapshot, error)

RestoreSnapshot mocks eventsourced.EventStore.RestoreSnapshot by calling RestoreSnapshotFunc or by returning nil, nil if RestoreSnapshotFunc is nil

func (*Store) StoreEvent

func (m *Store) StoreEvent(
	_ context.Context,
	aggregate eventsourced.Aggregate,
	event eventsourced.Event,
	sequenceNo int,
	newAggregate bool,
) error

StoreEvent mocks eventsourced.EventStore.StoreEvent by calling StoreEventFunc or by returning 0, nil if StoreEventFunc is nil

func (*Store) StoreSnapshot

func (m *Store) StoreSnapshot(_ context.Context, aggregate eventsourced.Aggregate, sequenceNo int) error

StoreSnapshot mocks eventsourced.EventStore.StoreSnapshot by calling StoreSnapshotFunc or by returning nil if StoreSnapshotFunc is nil

Jump to

Keyboard shortcuts

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