Current section

Files

Jump to
finitomata lib mix tasks test_template.eex
Raw

lib/mix/tasks/test_template.eex

defmodule <%= inspect(@test_module) %> do
use ExUnit.Case
import Finitomata.ExUnit
import Mox
<%= for {{path_def, path}, number} <- Enum.with_index(@paths) do %>
describe "<%= path_def |> inspect() |> String.replace(~r/⇥ \"[\w!?]+\" /, "") %>" do
setup_finitomata do
# *************************************
# **** PUT THE INITIALIZATION HERE ****
# *************************************
# **** context example:
parent = self()
[
fsm: [
implementation: <%= inspect(@module) %>,
payload: %{},
options: [transition_count: <%= length(path) + 1 %>]
],
context: [parent: parent]
]
end
test_path "path #<%= number %>", %{parent: _parent} = _ctx do
<%= for [{event, state} | states] <- path, event != :__start__ do %>
{<%= inspect(event) %>, nil} ->
assert_state <%= inspect(state) %> do
assert_payload do
# foo.bar.baz ~> ^parent
end
end
<%= for {_event, state} <- states do %>
assert_state <%= inspect(state) %> do
assert_payload do
# baz ~> ^parent
end
end <% end %> <% end %>
end
end <% end %>
end