helpers

package
v0.0.0-...-3414fa2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDatabaseState

func AssertDatabaseState(t *testing.T, db *DBHelper, checks map[string]int64)

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

func AssertOrderStatus(t *testing.T, db *DBHelper, orderNo string, expectedStatus int64)

AssertOrderStatus verifies the order status

func AssertPaymentStatus

func AssertPaymentStatus(t *testing.T, db *DBHelper, paymentNo string, expectedStatus int64)

AssertPaymentStatus verifies the payment status

func AssertRefundStatus

func AssertRefundStatus(t *testing.T, db *DBHelper, refundNo string, expectedStatus int64)

AssertRefundStatus verifies the refund status

func LoadFixture

func LoadFixture(filename string, v interface{}) error

For backward compatibility

func SaveFixture

func SaveFixture(filename string, v interface{}) error

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

func (h *DBHelper) CleanTestData(ctx context.Context) error

CleanTestData removes test data from all relevant tables

func (*DBHelper) Close

func (h *DBHelper) Close() error

Close closes the database connections

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) Close

func (h *RMQHelper) Close() error

Close closes the RabbitMQ connection and channel

func (*RMQHelper) ConsumeMessage

func (h *RMQHelper) ConsumeMessage(queueName string, timeout time.Duration) (*amqp.Delivery, error)

func (*RMQHelper) GetChannel

func (h *RMQHelper) GetChannel() *amqp.Channel

GetChannel returns the underlying AMQP channel

func (*RMQHelper) IsConnected

func (h *RMQHelper) IsConnected() bool

IsConnected checks if the broker connection is still alive

func (*RMQHelper) PublishEvent

func (h *RMQHelper) PublishEvent(exchange, routingKey string, event interface{}) error

PublishEvent publishes an event message to the specified exchange

func (*RMQHelper) SetupTestQueues

func (h *RMQHelper) SetupTestQueues() error

SetupTestQueues declares required exchanges and queues for testing

Jump to

Keyboard shortcuts

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