Documentation
¶
Index ¶
- func AssertDatabaseState(t *testing.T, db *DBHelper, checks map[string]int64)
- func AssertMessageContent(t *testing.T, msg *amqp.Delivery, expectedType string, ...)
- func AssertMessageReceived(t *testing.T, rmq RMQAssertions, queueName string, timeout time.Duration) *amqp.Delivery
- func AssertNoMessageReceived(t *testing.T, rmq RMQAssertions, queueName string, timeout time.Duration)
- func AssertOrderStatus(t *testing.T, db *DBHelper, orderNo string, expectedStatus int64)
- func AssertPaymentStatus(t *testing.T, db *DBHelper, paymentNo string, expectedStatus int64)
- func AssertRefundStatus(t *testing.T, db *DBHelper, refundNo string, expectedStatus int64)
- func LoadFixture(filename string, v interface{}) error
- func SaveFixture(filename string, v interface{}) error
- type DBAssertions
- type DBHelper
- type FixtureHelper
- type RMQAssertions
- type RMQHelper
- func (h *RMQHelper) Close() error
- func (h *RMQHelper) ConsumeMessage(queueName string, timeout time.Duration) (*amqp.Delivery, error)
- func (h *RMQHelper) GetChannel() *amqp.Channel
- func (h *RMQHelper) IsConnected() bool
- func (h *RMQHelper) PublishEvent(exchange, routingKey string, event interface{}) error
- func (h *RMQHelper) SetupTestQueues() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertDatabaseState ¶
AssertDatabaseState verifies multiple database conditions in one call
func AssertMessageContent ¶
func AssertMessageContent(t *testing.T, msg *amqp.Delivery, expectedType string, expectedRoutingKey string)
AssertMessageContent verifies the message content matches expected data
func AssertMessageReceived ¶
func AssertMessageReceived(t *testing.T, rmq RMQAssertions, queueName string, timeout time.Duration) *amqp.Delivery
AssertMessageReceived checks if a message was received on the specified queue
func AssertNoMessageReceived ¶
func AssertNoMessageReceived(t *testing.T, rmq RMQAssertions, queueName string, timeout time.Duration)
AssertNoMessageReceived verifies that no message is received within timeout
func AssertOrderStatus ¶
AssertOrderStatus verifies the order status
func AssertPaymentStatus ¶
AssertPaymentStatus verifies the payment status
func AssertRefundStatus ¶
AssertRefundStatus verifies the refund status
func LoadFixture ¶
For backward compatibility
func SaveFixture ¶
Types ¶
type DBAssertions ¶
type DBAssertions interface { GetOrderByNo(ctx context.Context, orderNo string) (interface{}, error) GetPaymentByNo(ctx context.Context, paymentNo string) (interface{}, error) GetRefundByNo(ctx context.Context, refundNo string) (interface{}, error) }
DBAssertions defines interface for database related assertions
type DBHelper ¶
type DBHelper struct {
// contains filtered or unexported fields
}
func NewDBHelper ¶
func NewDBHelper(mysqlDSN string, redisConf cache.ClusterConf) (*DBHelper, error)
NewDBHelper creates a new database helper with the given configuration
func (*DBHelper) CleanTestData ¶
CleanTestData removes test data from all relevant tables
func (*DBHelper) GetOrdersModel ¶
func (h *DBHelper) GetOrdersModel() model.OrdersModel
GetOrdersModel returns the orders model
func (*DBHelper) GetPaymentsModel ¶
func (h *DBHelper) GetPaymentsModel() model.OrderPaymentsModel
GetPaymentsModel returns the payments model
func (*DBHelper) GetRefundsModel ¶
func (h *DBHelper) GetRefundsModel() model.OrderRefundsModel
GetRefundsModel returns the refunds model
type FixtureHelper ¶
type FixtureHelper struct {
// contains filtered or unexported fields
}
FixtureHelper handles test fixture operations
func NewFixtureHelper ¶
func NewFixtureHelper() *FixtureHelper
NewFixtureHelper creates a new fixture helper
func (*FixtureHelper) LoadFixture ¶
func (h *FixtureHelper) LoadFixture(filename string, v interface{}) error
LoadFixture loads test data from JSON file
func (*FixtureHelper) LoadFixtureString ¶
func (h *FixtureHelper) LoadFixtureString(filename string) (string, error)
LoadFixtureString loads fixture data as a string
func (*FixtureHelper) SaveFixture ¶
func (h *FixtureHelper) SaveFixture(filename string, v interface{}) error
SaveFixture saves test data to JSON file
func (*FixtureHelper) ValidateFixture ¶
func (h *FixtureHelper) ValidateFixture(filename string) error
ValidateFixture checks if the fixture file exists and contains valid JSON
type RMQAssertions ¶
type RMQAssertions interface {
ConsumeMessage(queueName string, timeout time.Duration) (*amqp.Delivery, error)
}
RMQAssertions defines interface for RabbitMQ related assertions
type RMQHelper ¶
type RMQHelper struct {
// contains filtered or unexported fields
}
func NewRMQHelper ¶
func NewRMQHelper(config *rmqconfig.RabbitMQConfig) (*RMQHelper, error)
NewRMQHelper creates a new RMQ helper with given configuration
func (*RMQHelper) ConsumeMessage ¶
func (*RMQHelper) GetChannel ¶
GetChannel returns the underlying AMQP channel
func (*RMQHelper) IsConnected ¶
IsConnected checks if the broker connection is still alive
func (*RMQHelper) PublishEvent ¶
PublishEvent publishes an event message to the specified exchange
func (*RMQHelper) SetupTestQueues ¶
SetupTestQueues declares required exchanges and queues for testing