fix existing flakiness + cut runtime closes #533 #544
1 changed files with 2 additions and 12 deletions
|
|
@ -24,21 +24,11 @@ defmodule Mv.SeedsTest do
|
||||||
|
|
||||||
require Ash.Query
|
require Ash.Query
|
||||||
|
|
||||||
# Module attribute to track if seeds have been run
|
|
||||||
# This allows us to run seeds once per test module while respecting sandbox isolation
|
|
||||||
@seeds_run_key :seeds_test_run
|
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
system_actor = Mv.Helpers.SystemActor.get_system_actor()
|
system_actor = Mv.Helpers.SystemActor.get_system_actor()
|
||||||
|
|
||||||
# Run seeds once per test process (due to sandbox isolation, each test runs in its own process)
|
# Each test runs in its own sandbox-owned process, so seeds are loaded once per test.
|
||||||
# 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")
|
Code.eval_file("priv/repo/seeds.exs")
|
||||||
Process.put(@seeds_run_key, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
%{actor: system_actor}
|
%{actor: system_actor}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue