Packages
commanded
0.16.0-rc.0
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.3
1.4.2
1.4.1
1.4.0
1.4.0-rc.0
1.3.1
1.3.0
1.2.0
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-rc.1
1.0.0-rc.0
0.19.1
0.19.0
0.18.1
0.18.0
0.17.5
0.17.4
0.17.3
0.17.2
0.17.1
0.17.0
0.16.0
0.16.0-rc.1
0.16.0-rc.0
0.15.1
0.15.0
0.14.0
0.14.0-rc.0
0.13.0
0.12.0
0.11.0
0.10.0
0.9.0
0.8.5
0.8.4
0.8.3
0.8.1
0.8.0
0.7.1
0.6.2
0.6.1
0.6.0
0.4.0
0.3.1
0.3.0
0.2.1
0.2.0
0.1.0
Use Commanded to build your own Elixir applications following the CQRS/ES pattern.
Current section
Files
Jump to
Current section
Files
test/process_managers/multi_routing_test.exs
defmodule Commanded.ProcessManager.MultiRoutingTest do
use Commanded.StorageCase
import Commanded.Assertions.EventAssertions
alias Commanded.ProcessManagers.ProcessRouter
alias Commanded.ProcessManagers.{TodoProcessManager, TodoRouter}
alias Commanded.ProcessManagers.Todo.Commands.CreateTodo
alias Commanded.ProcessManagers.Todo.Events.TodoDone
alias Commanded.ProcessManagers.TodoList.Commands.{CreateList, MarkAllDone}
alias Commanded.ProcessManagers.TodoList.Events.ListAllDone
test "should create process instance for each identifier returned by `interested?/2`" do
{:ok, pm} = TodoProcessManager.start_link()
todo1_uuid = create_todo()
todo2_uuid = create_todo()
todo3_uuid = create_todo()
list_uuid = create_list_of_todos([todo1_uuid, todo2_uuid, todo3_uuid])
# mark list done should mark individual TODOs as done via process manager
:ok = TodoRouter.dispatch(%MarkAllDone{list_uuid: list_uuid})
assert_receive_event(ListAllDone, fn done -> done.list_uuid == list_uuid end)
assert_receive_event(TodoDone, fn done -> done.todo_uuid == todo1_uuid end, fn done ->
assert done.todo_uuid == todo1_uuid
end)
assert_receive_event(TodoDone, fn done -> done.todo_uuid == todo2_uuid end, fn done ->
assert done.todo_uuid == todo2_uuid
end)
assert_receive_event(TodoDone, fn done -> done.todo_uuid == todo3_uuid end, fn done ->
assert done.todo_uuid == todo3_uuid
end)
instances = ProcessRouter.process_instances(pm)
assert length(instances) == 3
end
defp create_todo do
todo_uuid = UUID.uuid4()
:ok = TodoRouter.dispatch(%CreateTodo{todo_uuid: todo_uuid})
todo_uuid
end
defp create_list_of_todos(todo_uuids) do
list_uuid = UUID.uuid4()
:ok = TodoRouter.dispatch(%CreateList{list_uuid: list_uuid, todo_uuids: todo_uuids})
list_uuid
end
end