testutils

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultCurrencyCode is the default currency code used in tests
	DefaultCurrencyCode = "USD"
	// DefaultAmount is the default amount used in tests (100.00)
	DefaultAmount = 100.0
	// DefaultFeeAmount is the default fee amount used in tests (1.00)
	DefaultFeeAmount = 1.0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type TestEvent

type TestEvent struct{}

func (*TestEvent) Type

func (e *TestEvent) Type() string

type TestHelper

type TestHelper struct {
	T                   *testing.T
	Handler             eventbus.HandlerFunc
	MockPaymentProvider *mocks.PaymentProvider
	Ctx                 context.Context
	Bus                 *mocks.Bus
	UOW                 *mocks.UnitOfWork
	MockAccRepo         *mocks.AccountRepository
	MockTxRepo          *mocks.TransactionRepository
	Logger              *slog.Logger

	// Test data
	UserID        uuid.UUID
	AccountID     uuid.UUID
	PaymentID     *string
	EventID       uuid.UUID
	CorrelationID uuid.UUID
	TransactionID uuid.UUID
	Amount        *money.Money
	FeeAmount     *money.Money
}

TestHelper contains all test dependencies and helper methods

func New

func New(t *testing.T, opts ...TestOption) *TestHelper

New creates a new test helper with fresh mocks and test data

func (*TestHelper) AssertExpectations

func (h *TestHelper) AssertExpectations()

AssertExpectations asserts all mock expectations

func (*TestHelper) CreateValidAccount

func (h *TestHelper) CreateValidAccount() *dto.AccountRead

CreateValidAccount creates a test account DTO

func (*TestHelper) CreateValidTransaction

func (h *TestHelper) CreateValidTransaction() *dto.TransactionRead

CreateValidTransaction creates a test transaction DTO

func (*TestHelper) SetupMocks

func (h *TestHelper) SetupMocks()

SetupMocks configures the default mock expectations

func (*TestHelper) WithAccountID

func (h *TestHelper) WithAccountID(id uuid.UUID) *TestHelper

WithAccountID sets a custom account ID for the test helper

func (*TestHelper) WithAmount

func (h *TestHelper) WithAmount(amount *money.Money) *TestHelper

WithAmount sets a custom amount for the test helper

func (*TestHelper) WithContext

func (h *TestHelper) WithContext(ctx context.Context) *TestHelper

WithContext sets the context for the test helper

func (*TestHelper) WithFeeAmount

func (h *TestHelper) WithFeeAmount(amount *money.Money) *TestHelper

WithFeeAmount sets a custom fee amount for the test helper

func (*TestHelper) WithHandler

func (h *TestHelper) WithHandler(
	handler eventbus.HandlerFunc) *TestHelper

WithHandler sets a custom handler for the test helper

func (*TestHelper) WithPaymentID

func (h *TestHelper) WithPaymentID(id *string) *TestHelper

WithPaymentID sets a custom payment ID for the test helper

func (*TestHelper) WithTransactionID

func (h *TestHelper) WithTransactionID(d uuid.UUID) *TestHelper

WithTransactionID sets a custom transaction ID for the test helper

func (*TestHelper) WithUserID

func (h *TestHelper) WithUserID(id uuid.UUID) *TestHelper

WithUserID sets a custom user ID for the test helper

type TestOption

type TestOption func(*TestHelper)

TestOption defines a function type for test options

Jump to

Keyboard shortcuts

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