New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resetting between tests #177
Comments
You might find it easier to following the guidance on the Testing your application wiki page which uses the Postgres database and resets the storage after each test run. |
setup function in my setup do
{:ok, event_store_pid} = Commanded.EventStore.Adapters.InMemory.start_link()
{:ok, _} = Application.ensure_all_started(:my_app)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(OpenGovernment.Repo)
Ecto.Adapters.SQL.Sandbox.mode(OpenGovernment.Repo, {:shared, self()})
on_exit(fn ->
:ok = Application.stop(:my_app)
Process.unlink(event_store_pid)
Process.exit(event_store_pid, :shutdown)
ref = Process.monitor(event_store_pid)
assert_receive {:DOWN, ^ref, _, _, _}, 5_000
end)
:ok
end when starting tests, i get ** (ArgumentError) argument error
(stdlib) :ets.lookup_element(Ecto.Registry, nil, 3)
(ecto) lib/ecto/registry.ex:18: Ecto.Registry.lookup/1
(ecto) lib/ecto/adapters/sql/sandbox.ex:426: Ecto.Adapters.SQL.Sandbox.mode/2
(elixir) lib/code.ex:677: Code.require_file/2
(elixir) lib/enum.ex:737: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:737: Enum.each/2
(mix) lib/mix/tasks/test.ex:256: Mix.Tasks.Test.run/1
(mix) lib/mix/task.ex:314: Mix.Task.run_task/3
(mix) lib/mix/task.ex:348: Mix.Task.run_alias/3
(mix) lib/mix/task.ex:277: Mix.Task.run/2
(mix) lib/mix/project.ex:351: Mix.Project.in_project/4
(elixir) lib/file.ex:1419: File.cd!/2
(mix) lib/mix/task.ex:414: anonymous fn/4 in Mix.Task.recur/1
(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
(mix) lib/mix/task.ex:413: Mix.Task.recur/1
(mix) lib/mix/project_stack.ex:141: Mix.ProjectStack.recur/1
(mix) lib/mix/cli.ex:80: Mix.CLI.run_task/2 if i use ** (ArgumentError) argument error
(stdlib) :ets.lookup_element(Ecto.Registry, nil, 3)
(ecto) lib/ecto/registry.ex:18: Ecto.Registry.lookup/1
(ecto) lib/ecto/adapters/sql/sandbox.ex:426: Ecto.Adapters.SQL.Sandbox.mode/2
(elixir) lib/code.ex:677: Code.require_file/2
(elixir) lib/enum.ex:737: Enum."-each/2-lists^foreach/1-0-"/2 |
The in-memory event store page in the wiki has been updated with the approach used by Commanded to test event store integration (in |
The |
@slashdotdash the |
@fribmendes I configure ExUnit to capture the log so it only outputs logging statements when a test fails. This hides any irrelevant logged warnings or errors. # config/test.exs
config :ex_unit, capture_log: true |
I'm trying to reset the event store and commanded between tests.
I'm using the
InMemory
event store, currently usingreset!/0
to reset its memory. However, I still have issues with tests failing due to subscriptions not being reset and process managers keeping their state between consecutive tests.I've tried the option of restarting the application and commanded between each test but so far it hasn't worked (is it possible that the process managers are orphaned somehow?). I have also tried rebasing the
feature/in-memory-reset
branch and use it, but unsuccessful so far.Errors included:
The text was updated successfully, but these errors were encountered: