Conduit v0.7.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

Macros

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

Macros

__using__(arg1)

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
assert_message_publish(message, timeout \\ 100)

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)
assert_message_published(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)
assert_message_published(message, opts)

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)
refute_message_publish(message, timeout \\ 100)

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

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