rabbittest

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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 *channel.Reopener
}

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. It is possible to override created exchange, queue or routing key by overriding SetupTest method:

func (s *MySuite) SetupTest() {
	s.TopologySuite.Queue = "other-queue-name"
	s.TopologySuite.SetupTest()
}

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.

Jump to

Keyboard shortcuts

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