Skip to content

Instantly share code, notes, and snippets.

@ben-ole
Created July 3, 2018 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ben-ole/ff8df40d0487246b7dc14c1d2bef4078 to your computer and use it in GitHub Desktop.
Save ben-ole/ff8df40d0487246b7dc14c1d2bef4078 to your computer and use it in GitHub Desktop.
KaufmannEx TestSupport
defmodule Sample.EventHandlerTest do
use KaufmannEx.TestSupport.MockBus
test "Events Can Be published & observed" do
given_event(:"command.user.create", %{user_name: "Test User", user_email: "test@example.com"})
assert %{
payload: %{user_id: uknown_id}
} = then_event(:"event.test")
end
test "Effects of consumed events can be observed" do
given_event(:"command.user.create", %{user_name: "Test User", user_email: "test@example.com"})
assert Sample.User.user_exists?("test@example.com")
end
test "other actions that trigger events can be tested" do
Sample.SomeModule.update_user(id: 1, name: "George")
assert %{payload: %{name: "George" }} = then_event(:"command.user.update")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment