Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- amqpSpec :: TestDefM (RabbitMQHandle ': outers) Connection result -> TestDefM outers inner result
- amqpConnectionSetupFunc :: RabbitMQHandle -> SetupFunc Connection
Documentation
amqpSpec :: TestDefM (RabbitMQHandle ': outers) Connection result -> TestDefM outers inner result Source #
Run a rabbitmq server around a group of test, and provide a clean connection to each individual test
Example usage
spec :: Spec spec = describe "amqpSpec" $ do it "can write and read a message" $ \conn -> do chan <- openChannel conn -- declare a queue, exchange and binding _ <- declareQueue chan newQueue {queueName = "myQueue"} declareExchange chan newExchange {exchangeName = "myExchange", exchangeType = "direct"} bindQueue chan "myQueue" "myExchange" "myKey" -- publish a message to our new exchange let body = "hello world" _ <- publishMsg chan "myExchange" "myKey" newMsg { msgBody = body, msgDeliveryMode = Just Persistent } mMesg <- getMsg chan Ack "myQueue" case mMesg of Nothing -> expectationFailure "Should have received a message" Just (m, e) -> do msgBody m `shouldBe` body ackEnv e
amqpConnectionSetupFunc :: RabbitMQHandle -> SetupFunc Connection Source #
Setup function for a connection to a given rabbitmq server