wabbit
wabbit copied to clipboard
Examples for usage with streadway/amqp
It's mentioned in the readme that this should be possible but I'm wonder if we could get some examples showing this.
For example I'd like to mock the server/connection/channel then pass that down to my function which uses streadway/amqp from that point on.
You inject a wabbit.Conn to your function.
In your test, you can attack a fake server or a real server like this:
url := "amqp://localhost:32771"
isRealServer := true
var err error
var conn wabbit.Conn
if isRealServer {
conn, err = amqp.Dial(url)
} else {
fakeServer := server.NewServer(url)
fakeServer.Start()
conn, err = amqptest.Dial(url)
}
assert.NoError(t, err)
I for e.g pass the conn to my rabbitMQMessageBroker constructor, it will setup the exchanges, setup the queue etc.