Documentation ¶
Overview ¶
a Logger implementation for tests
Index ¶
- func CaptureOutput(f func()) string
- func IntegrationAPIURIFromEnv() string
- func IntegrationQueueName(i int) string
- func IntegrationTestConnection(t *testing.T, exchangeName, exchangeType string, numQueues int, ...) (*amqp.Connection, *amqp.Channel)
- func IntegrationURIFromEnv() *url.URL
- func NewRabbitAPIMock(mode MockMode) *httptest.Server
- func PublishTestMessages(t *testing.T, ch *amqp.Channel, numMessages int, ...)
- func VerifyTestMessageOnQueue(t *testing.T, ch *amqp.Channel, consumer string, numExpected int, ...)
- type MockMode
- type TestLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureOutput ¶
func CaptureOutput(f func()) string
CaptureOutput captures all output written to stdout, stderr and returns it as string credits: https://medium.com/@hau12a1/golang-capturing-log-println-and-fmt-println-output-770209c791b4
func IntegrationAPIURIFromEnv ¶
func IntegrationAPIURIFromEnv() string
IntegrationAPIURIFromEnv return the REST API URL to use for tests
func IntegrationQueueName ¶
IntegrationQueueName returns the name of the ith test queue
func IntegrationTestConnection ¶
func IntegrationTestConnection(t *testing.T, exchangeName, exchangeType string, numQueues int, addRoutingHeader bool) (*amqp.Connection, *amqp.Channel)
IntegrationTestConnection creates connection to rabbitmq broker and sets up optionally an exchange of the given type and bind given number of queues to the exchange. The binding key will aways be the queue name. The queues are named "queue-0" "queue-1" etc (see integrationQueueName() func). If parameter addRoutingHeader is true, then the queue will be bound using an additional routing header ("x-match":"any", "header1":"test0" for first queue etc; this feature is needed by the headers test).
func IntegrationURIFromEnv ¶
IntegrationURIFromEnv return the amqp URL to use for tests
func NewRabbitAPIMock ¶
NewRabbitAPIMock returns a mock server for the rabbitmq http managemet API. It is used by the integration test. Only a very limited subset of resources is support (GET exchanges, bindings, queues, overviews, channels, connections; DELETE connections) Usage:
mockServer := NewRabbitAPIMock(MockModeStd) defer mockServer.Close() client f := NewRabbitHTTPClient(mockServe.URL)
func PublishTestMessages ¶
func PublishTestMessages(t *testing.T, ch *amqp.Channel, numMessages int, exchangeName, routingKey string, optHeaders amqp.Table)
PublishTestMessages publishes the given number of test messages the exchange exhangeName with the provided routingKey
func VerifyTestMessageOnQueue ¶
func VerifyTestMessageOnQueue(t *testing.T, ch *amqp.Channel, consumer string, numExpected int, queueName string, success chan int)
VerifyTestMessageOnQueue checks that the expected messages were received on the given queue. on success the number of received messages is sent through the provided success channel signalling success.
Types ¶
type TestLogger ¶
type TestLogger struct{}
func NewTestLogger ¶
func NewTestLogger() *TestLogger
func (TestLogger) Debugf ¶
func (s TestLogger) Debugf(format string, a ...interface{})
func (TestLogger) Errorf ¶
func (s TestLogger) Errorf(format string, a ...interface{})
func (TestLogger) Infof ¶
func (s TestLogger) Infof(format string, a ...interface{})