diff --git a/test/test_helper.exs b/test/test_helper.exs index eb666866..41ac09ec 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -39,6 +39,14 @@ end # DBConnection.Ownership from the app env and initializes with it. {:ok, _} = Application.ensure_all_started(:microwaveprop) +# Clean up any rows left behind by a crashed or killed prior run. +# The sandbox rolls back per-test, but if the suite itself crashes +# mid-run, committed data persists and causes count-mismatch failures +# in the next run. Wipe known test-data tables before each suite. +for table <- ~w(contacts hrrr_fetch_tasks iemre_observations oban_jobs) do + Microwaveprop.Repo.delete_all(table) +end + # stream_data is a test-only dep — its ebin is on the code path from the # wildcard above, but the application isn't started. `check all` etc. # call Application.fetch_env!(:stream_data, :initial_size), which needs