Conduit v0.8.0 Conduit.Test
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 thatpublish` on your broker, was called in.
Summary
Functions
If another process is responsible for publishing a Conduit.Message,
you must
Asserts that a Conduit.Message will be published
Asserts that a Conduit.Message was published
Asserts that a Conduit.Message was published with specific options
Refutes that a Conduit.Message will be published
Refutes that a Conduit.Message was published
Refutes that a Conduit.Message was published with specific options
Functions
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
Asserts that a Conduit.Message will be published.
Accepts a pattern for the message and a timeout for how long to wait
for the message. Timeout defaults to 100 ms.
Examples
assert_message_publish(%{body: body})
assert_message_publish(^message)
Asserts that a Conduit.Message was published.
Same as Conduit.Test.assert_message_publish/2, but with timeout
set to 0.
Examples
assert_message_published(%{body: body})
assert_message_published(^message)
Asserts that a Conduit.Message was published with specific options.
Same as Conduit.Test.assert_message_publish/3, but with timeout
set to 0.
Examples
assert_message_published(%{body: body}, [to: to])
assert_message_published(^message, ^opts)
Refutes that a Conduit.Message will be published.
Accepts a pattern for the message and a timeout for how long to wait
for the message. Timeout defaults to 100 ms.
Examples
refute_message_publish(%{body: body})
refute_message_publish(^message)
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 with specific options.
Same as Conduit.Test.refute_message_publish/3, but with timeout
set to 0.
Examples
refute_message_published(^message, ^opts)
refute_message_published(_, _)