Documentation
¶
Overview ¶
Package grmqt provides test helpers for RabbitMQ operations. It creates isolated virtual hosts for each test and automatically cleans them up after the test completes.
Index ¶
- type Client
- func (c *Client) ConnectionConfig() grmqx.Connection
- func (c *Client) DrainMessage(queue string) amqp091.Delivery
- func (c *Client) Publish(exchange string, routingKey string, messages ...amqp091.Publishing)
- func (c *Client) PublishJson(exchange string, routingKey string, data any)
- func (c *Client) QueueLength(queue string) int
- func (c *Client) Upgrade(config grmqx.Config)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client provides a test helper for RabbitMQ operations. It manages a dedicated connection and virtual host for each test.
func New ¶
New creates a new RabbitMQ test client with an isolated virtual host. The virtual host is created before the test and automatically deleted when the test completes. Connection parameters can be overridden using environment variables: RMQ_HOST, RMQ_PORT, RMQ_USER, RMQ_PASS.
nolint:nosprintfhostport,noctx,bodyclose,mnd
func (*Client) ConnectionConfig ¶
func (c *Client) ConnectionConfig() grmqx.Connection
ConnectionConfig returns the connection configuration used by the client.
func (*Client) DrainMessage ¶
DrainMessage retrieves and returns a single message from the specified queue. Panics if no message is available.
func (*Client) Publish ¶
func (c *Client) Publish(exchange string, routingKey string, messages ...amqp091.Publishing)
Publish publishes one or more messages to the specified exchange and routing key. Panics if publishing fails.
func (*Client) PublishJson ¶
PublishJson publishes a JSON-encoded message to the specified exchange and routing key. Panics if JSON marshaling or publishing fails.
func (*Client) QueueLength ¶
QueueLength returns the number of messages in the specified queue.