diff --git a/test/seeds_test.exs b/test/seeds_test.exs index d26ed59..e40a23f 100644 --- a/test/seeds_test.exs +++ b/test/seeds_test.exs @@ -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)