Conduit v0.12.10 Conduit.Test View Source
Helpers for testing receiving and publishing messages from a message queue.
The helpers in this module are intended to be used in conjunction
with the Conduit.TestAdapter
. When you publish a Conduit.Message
with the Conduit.TestAdapter
setup, it will send a message to the
same process that publish
on your broker, was called in.
If another process is responsible for publishing a Conduit.Message
,
you must:
- Pass
[shared: true]
when usingConduit.Test
- Pass
[async: false]
when usingExUnit.Case
This is necessary, because the helpers and the adapter must share
configuration to know what the test process is. If async
is true
,
multiple tests could override test process and the publish
notification would go to the wrong process.
Examples
# Unit Testing
use ExUnit.Case, async: true
use Conduit.Test, shared: false
# Integration Testing
use ExUnit.Case, async: false
use Conduit.Test, shared: true
Link to this section Summary
Functions
Asserts that a Conduit.Message
will be published
Asserts that a Conduit.Message
will be published
Asserts that a Conduit.Message
will be published
Asserts that a Conduit.Message
will be published
Asserts that a message was published
Asserts that a message was published
Asserts that a message was published with specific options
Refutes that a Conduit.Message
will be published
Refutes that a Conduit.Message
will be published
Refutes that a Conduit.Message
will be published
Refutes that a Conduit.Message
will be published
Refutes that a Conduit.Message
was published
Refutes that a Conduit.Message
was published
Refutes that a Conduit.Message
was published with specific options
Link to this section Functions
Asserts that a Conduit.Message
will be published.
Accepts the name of the route
. timeout
after 100 ms.
Examples
MyApp.Broker.publish(:message, %Conduit.Message{})
assert_message_publish(:message)
assert_message_publish(_)
Asserts that a Conduit.Message
will be published.
Accepts the name of the route
and a pattern for the message
or a timeout
for
how long to wait for the message
. If a message
pattern is passed, timeout
defaults to 100 ms.
Examples
MyApp.Broker.publish(:message, %Conduit.Message{})
assert_message_publish(:message, 200)
assert_message_publish(:message, ^message)
Asserts that a Conduit.Message
will be published.
Accepts the name of the route
, a pattern for the message
, and a pattern for the options
or a timeout
for
how long to wait for the message
. If a options
pattern is passed, timeout
defaults to 100 ms.
Examples
MyApp.Broker.publish(:message, %Conduit.Message{}, to: "here")
assert_message_publish(:message, %{body: body}, 200)
assert_message_publish(:message, %{body: body}, [to: "here"])
assert_message_publish(:message, ^message, 300)
Asserts that a Conduit.Message
will be published.
Accepts the name of the route
, a pattern for the message
, a pattern for the options
, and a timeout
for
how long to wait for the message
.
Examples
MyApp.Broker.publish(:message, %Conduit.Message{}, to: "here")
assert_message_publish(:message, %{body: body}, [to: "here"], 200)
assert_message_publish(:message, message, [to: "here"], 300)
assert_message_publish(:message, ^message, ^opts, 300)
Asserts that a message was published.
Same as Conduit.Test.assert_message_publish/2
, but with timeout
set to 0.
Examples
MyApp.Broker.publish(:message, %Conduit.Message{})
assert_message_published(:message)
Asserts that a message was published.
Same as Conduit.Test.assert_message_publish/3
, but with timeout
set to 0.
Examples
MyApp.Broker.publish(:message, %Conduit.Message{})
assert_message_published(:message, %Conduit.Message{body: body})
assert_message_published(:message, message)
assert_message_published(:message, ^message)
Asserts that a message was published with specific options.
Same as Conduit.Test.assert_message_publish/4
, but with timeout
set to 0.
Examples
MyApp.Broker.publish(:message, %Conduit.Message{}, to: "queue")
assert_message_published(:message, %Conduit.Message{body: body}, [to: "queue"])
assert_message_published(:message, message, [to: destination])
assert_message_published(:message, ^message, ^opts)
Refutes that a Conduit.Message
will be published.
Accepts the name of the route
. Timeout defaults to 100
ms.
Examples
refute_message_publish(:message)
Refutes that a Conduit.Message
will be published.
Accepts the name of the route
and a pattern for the message
or a timeout
for how long to wait
for the message
. If a message
pattern is passed, timeout defaults to 100
ms.
Examples
refute_message_publish(:message, 200)
refute_message_publish(:message, %{body: body})
refute_message_publish(:message, ^message)
Refutes that a Conduit.Message
will be published.
Accepts the name of the route
, a pattern for the message
, and a pattern for options
or a timeout
for how
long to wait for the message
. If a options
pattern is passed, timeout defaults to 100
ms.
Examples
refute_message_publish(:message, %Conduit.Message{}, 200)
refute_message_publish(:message, %{body: body}, [to: "elsewhere"])
refute_message_publish(:message, ^message, ^options)
Refutes that a Conduit.Message
will be published.
Accepts the name of the route
, a pattern for the message
, a pattern for options
, and a timeout
for how
long to wait for the message
.
Examples
refute_message_publish(:message, %Conduit.Message{}, [to: "elsewhere"], 200)
refute_message_publish(:message, %{body: body}, [to: "elsewhere"], 10)
refute_message_publish(:message, ^message, ^options, 50)
Refutes that a Conduit.Message
was published.
Same as Conduit.Test.refute_message_publish/2
, but with timeout
set to 0.
Examples
refute_message_published(:message)
refute_message_published(_)
Refutes that a Conduit.Message
was published.
Same as Conduit.Test.refute_message_publish/3
, but with timeout
set to 0.
Examples
MyApp.Broker.publish(:message, %Conduit.Message{body: "bar"})
refute_message_published(:message, %Conduit.Message{body: "foo"})
Refutes that a Conduit.Message
was published with specific options.
Same as Conduit.Test.refute_message_publish/4
, but with timeout
set to 0.
Examples
MyApp.Broker.publish(:message, %Conduit.Message{body: "bar"}, to: "queue")
refute_message_published(:message, %Conduit.Message{body: "bar"}, to: "elsewhere")