Documentation
¶
Overview ¶
Package rabbittest provides "stretchr/testify/suite" testing suite with prepared RabbitMQ connection, channel or topology.
Usage:
// embedding ChannelSuite
type TestSuite struct {
rabbittest.ChannelSuite
}
func (s *TestSuite) TestMyFunction() {
s.Channel.Publish(...)
}
Set up RABBITMQ_URL environment variable and tun tests:
RABBITMQ_URL=amqp://localhost:5672 go test -v ./...
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelSuite ¶
type ChannelSuite struct {
ConnectionSuite
Channel *amqp.Channel
}
ChannelSuite uses ConnectionSuite to create connection and then creates new channel for each test.
func (*ChannelSuite) SetupTest ¶
func (s *ChannelSuite) SetupTest()
SetupTest creates new channel. Implements suite.SetupTestSuite.
func (*ChannelSuite) TearDownTest ¶
func (s *ChannelSuite) TearDownTest()
TearDownTest closes channel. Implements suite.TearDownTestSuite.
type ConnectionSuite ¶
type ConnectionSuite struct {
suite.Suite
Connection *connection.Redialer
}
ConnectionSuite creates RabbitMQ connection on test setup.
func (*ConnectionSuite) SetupSuite ¶
func (s *ConnectionSuite) SetupSuite()
SetupSuite creates new RabbitMQ connection. Implements suite.SetupAllSuite.
func (*ConnectionSuite) TearDownSuite ¶
func (s *ConnectionSuite) TearDownSuite()
TearDownSuite closes RabbitMQ connection. Implements suite.TearDownAllSuite.
type TopologySuite ¶
type TopologySuite struct {
ChannelSuite
Exchange string
Queue string
Key string
}
TopologySuite uses ChannelSuite to create channel and then creates new topology using this channel.
func (*TopologySuite) SetupTest ¶
func (s *TopologySuite) SetupTest()
SetupTest creates exchange, queue and binds queue to be consume messages with Key. Implements suite.SetupTestSuite.
func (*TopologySuite) TearDownTest ¶
func (s *TopologySuite) TearDownTest()
TearDownTest deletes exchange and queue. Implements suite.TearDownTestSuite.