-
Notifications
You must be signed in to change notification settings - Fork 0
/
exchange.nim
29 lines (27 loc) · 1008 Bytes
/
exchange.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import std/[unittest, asyncdispatch]
import asyncrabbitmq/[asyncrabbitmq, connection, exchange]
suite "RabbitMQ exchange":
setup:
discard
test "Exchange declare/delete":
proc testChannelCreation() {.async} =
var address = "amqp://guest:guest@localhost/".fromURL()
var connection = newRabbitMQ(address, 1)
try:
await connection.connect()
checkpoint "Allocating channel"
let chan = await connection.openChannel()
checkpoint "Creating exchange"
let exchange = await chan.exchangeDeclare("testExchange", EXCHANGE_DIRECT)
check exchange.id == "testExchange"
checkpoint "Deleting the exchange"
await exchange.delete()
checkpoint "Closing the channel"
await chan.close()
except RMQConnectionFailed:
checkpoint "Can't connect to RabbitMQ instance"
fail()
finally:
checkpoint "Closing the connection"
await connection.close()
waitFor(testChannelCreation())