Minor test refactoring to improve on performance closes #383 #384
1 changed files with 5 additions and 2 deletions
|
|
@ -31,7 +31,10 @@ defmodule Mv.SeedsTest do
|
|||
setup do
|
||||
system_actor = Mv.Helpers.SystemActor.get_system_actor()
|
||||
|
||||
# Run seeds only once per test run (check process dictionary)
|
||||
# Run seeds once per test process (due to sandbox isolation, each test runs in its own process)
|
||||
# Process.get/put ensures seeds are only executed once per test process, not once per test
|
||||
# Note: With async: false and sandbox isolation, this effectively runs seeds once per test,
|
||||
# but the guard prevents multiple executions within the same test process if setup is called multiple times
|
||||
unless Process.get(@seeds_run_key) do
|
||||
Code.eval_file("priv/repo/seeds.exs")
|
||||
Process.put(@seeds_run_key, true)
|
||||
|
|
@ -55,7 +58,7 @@ defmodule Mv.SeedsTest do
|
|||
end
|
||||
|
||||
test "is idempotent when run multiple times", %{actor: actor} do
|
||||
# Seeds already run once in setup_all - count current state
|
||||
# Seeds already run once in setup - count current state
|
||||
{:ok, users_count_1} = Ash.read(Mv.Accounts.User, actor: actor)
|
||||
{:ok, members_count_1} = Ash.read(Mv.Membership.Member, actor: actor)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue