fix: clean stale test data before each suite run
Some checks failed
Build and Push / Build and Push Docker Image (push) Has been cancelled

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.
This commit is contained in:
Graham McIntire 2026-08-04 17:07:53 -05:00
parent 581955bd69
commit d35239ba1e
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -39,6 +39,14 @@ end
# DBConnection.Ownership from the app env and initializes with it. # DBConnection.Ownership from the app env and initializes with it.
{:ok, _} = Application.ensure_all_started(:microwaveprop) {: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 # 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. # wildcard above, but the application isn't started. `check all` etc.
# call Application.fetch_env!(:stream_data, :initial_size), which needs # call Application.fetch_env!(:stream_data, :initial_size), which needs