Documentation
¶
Index ¶
- Constants
- type TestEvent
- type TestHelper
- func (h *TestHelper) AssertExpectations()
- func (h *TestHelper) CreateValidAccount() *dto.AccountRead
- func (h *TestHelper) CreateValidTransaction() *dto.TransactionRead
- func (h *TestHelper) SetupMocks()
- func (h *TestHelper) WithAccountID(id uuid.UUID) *TestHelper
- func (h *TestHelper) WithAmount(amount money.Money) *TestHelper
- func (h *TestHelper) WithContext(ctx context.Context) *TestHelper
- func (h *TestHelper) WithFeeAmount(amount money.Money) *TestHelper
- func (h *TestHelper) WithHandler(handler eventbus.HandlerFunc) *TestHelper
- func (h *TestHelper) WithPaymentID(id string) *TestHelper
- func (h *TestHelper) WithTransactionID(d uuid.UUID) *TestHelper
- func (h *TestHelper) WithUserID(id uuid.UUID) *TestHelper
- type TestOption
Constants ¶
const ( // DefaultCurrency is the default currency used in tests DefaultCurrency = "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 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