Conduit v0.8.3 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 thatpublish` on your broker, was called in.

Link to this section Summary

Functions

If another process is responsible for publishing a Conduit.Message, you must

Asserts that a Conduit.Message was published

Asserts that a Conduit.Message was published with specific options

Refutes that a Conduit.Message was published

Refutes that a Conduit.Message was published with specific options

Link to this section Functions

Link to this macro __using__(arg1) View Source (macro)

If another process is responsible for publishing a Conduit.Message, you must:

  1. Pass [shared: true] when using Conduit.Test
  2. Pass [async: false] when using ExUnit.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 macro assert_message_publish(message, timeout \\ 100) View Source (macro)

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)
Link to this macro assert_message_published(message) View Source (macro)

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)
Link to this macro assert_message_published(message, opts) View Source (macro)

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)
Link to this macro refute_message_publish(message, timeout \\ 100) View Source (macro)

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)
Link to this macro refute_message_published(message) View Source (macro)

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(_)
Link to this macro refute_message_published(message, opts) View Source (macro)

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(_, _)