From d35239ba1ec699dd5acdb599ba64e7a8e5393087 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 4 Aug 2026 17:07:53 -0500 Subject: [PATCH] fix: clean stale test data before each suite run Rows left behind by a crashed/killed prior run persist because sandbox on_exit callbacks don't fire on BEAM crash or SIGKILL. Wipe known test-data tables (contacts, hrrr_fetch_tasks, iemre_observations, oban_jobs) after app boot so every suite starts clean regardless of previous run state. --- test/test_helper.exs | 8 ++++++++ 1 file changed, 8 insertions(+) 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