kaufmann_ex v0.3.2-beta KaufmannEx.TestSupport.MockBus
Helper module for testing event flows.
Cannot be run Async, relies on sending messages to self()
For every given_event/2 and then_event/2.
- Validates events against schemas registered with Schema registry
Injects generic Meta payload into given_event
then_event/2asserts that the given event is emitted and verifies or returned the payloadIf you have a custom metadata schema or specific metadata handling, set a module exporting
event_metadata/2in app_env:kaufmann_ex, :metadata_mod### Example Usage
defmodule EvenHandlerTests
use KaufmannEx.TestSupport.MockBus
test "event emission" do
given_event(:"TestCommand", %{new_key: "test"})
then_event(:"Testevent", %{new_key: "test"})
then_no_event
end
end
Link to this section Summary
Functions
Assert a named event is encodable by its specified schema
Dispatches event to the default subscriber
Asserts an event has been emitted, returns the payload
Asserts an event will be emitted to the bus
Asserts no more events will be emitted
Assert an event will not be emitted
Link to this section Functions
Assert a named event is encodable by its specified schema
Dispatches event to the default subscriber.
Schema must be defined & payload must be valid/enocodable
Asserts an event has been emitted, returns the payload
Returned payload will include meta metadata
Asserts an event will be emitted to the bus
Will test emitted payload from event matches payload Asserts payload matches argument
Asserts no more events will be emitted
Assert an event will not be emitted