From a6a71e8c946ceb18891d0e45bdb762bdf3ffd12a Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 12 Apr 2026 15:02:38 -0500 Subject: [PATCH] Fix BackfillEnqueueWorker test timeouts and credo length warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The three BackfillEnqueueWorkerTest cases were timing out because the default types list includes :era5, which cascades through inline Oban into Era5Client.poll_and_download where Process.sleep blocks for the full 60s test timeout. Era5Client uses bare Req.get with no plug hook, so it can't be stubbed via Req.Test the way the other clients are. Pass explicit non-ERA5 types in the three affected cases — ERA5 has its own coverage and these tests don't assert anything era5-specific. Also replace two `length(results) > 0` checks in asos_nudge_test with `results != []` to silence credo warnings. --- .../propagation/asos_nudge_test.exs | 4 +-- .../workers/backfill_enqueue_worker_test.exs | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/test/microwaveprop/propagation/asos_nudge_test.exs b/test/microwaveprop/propagation/asos_nudge_test.exs index b4a8d304..c445bee0 100644 --- a/test/microwaveprop/propagation/asos_nudge_test.exs +++ b/test/microwaveprop/propagation/asos_nudge_test.exs @@ -159,7 +159,7 @@ defmodule Microwaveprop.Propagation.AsosNudgeTest do results = AsosNudge.compute([obs], @valid_time, [hrrr]) - assert length(results) > 0 + assert results != [] for result <- results do assert result.lat == 32.0 @@ -189,7 +189,7 @@ defmodule Microwaveprop.Propagation.AsosNudgeTest do results = AsosNudge.compute([], @valid_time, [far_cell], rain_grid) - assert length(results) > 0 + assert results != [] lat_lons = results |> Enum.map(&{&1.lat, &1.lon}) |> Enum.uniq() assert {40.0, -85.0} in lat_lons end diff --git a/test/microwaveprop/workers/backfill_enqueue_worker_test.exs b/test/microwaveprop/workers/backfill_enqueue_worker_test.exs index 2b48df40..d7920f63 100644 --- a/test/microwaveprop/workers/backfill_enqueue_worker_test.exs +++ b/test/microwaveprop/workers/backfill_enqueue_worker_test.exs @@ -56,11 +56,19 @@ defmodule Microwaveprop.Workers.BackfillEnqueueWorkerTest do :ok end + # ERA5 goes through Copernicus CDS API which is async (submit → poll → download) + # and has no Req.Test plug hook, so inline Oban would block on Process.sleep. + # These tests exercise the non-ERA5 enrichment path; ERA5 has its own coverage. + @non_era5_types ["hrrr", "weather", "terrain", "iemre"] + describe "perform/1" do test "enqueues enrichment jobs for pending contacts" do create_contact() - assert :ok = BackfillEnqueueWorker.perform(%Oban.Job{args: %{"limit" => 10}}) + assert :ok = + BackfillEnqueueWorker.perform(%Oban.Job{ + args: %{"limit" => 10, "types" => @non_era5_types} + }) end test "does not enqueue for already-complete contacts" do @@ -75,7 +83,10 @@ defmodule Microwaveprop.Workers.BackfillEnqueueWorkerTest do }) |> Repo.update!() - assert :ok = BackfillEnqueueWorker.perform(%Oban.Job{args: %{"limit" => 10}}) + assert :ok = + BackfillEnqueueWorker.perform(%Oban.Job{ + args: %{"limit" => 10, "types" => @non_era5_types} + }) end test "respects limit parameter" do @@ -84,7 +95,10 @@ defmodule Microwaveprop.Workers.BackfillEnqueueWorkerTest do create_contact(%{qso_timestamp: ts}) end - assert :ok = BackfillEnqueueWorker.perform(%Oban.Job{args: %{"limit" => 2}}) + assert :ok = + BackfillEnqueueWorker.perform(%Oban.Job{ + args: %{"limit" => 2, "types" => @non_era5_types} + }) end test "broadcasts enqueue_complete with count" do @@ -92,7 +106,10 @@ defmodule Microwaveprop.Workers.BackfillEnqueueWorkerTest do create_contact() - assert :ok = BackfillEnqueueWorker.perform(%Oban.Job{args: %{"limit" => 10}}) + assert :ok = + BackfillEnqueueWorker.perform(%Oban.Job{ + args: %{"limit" => 10, "types" => @non_era5_types} + }) assert_receive {:enqueue_complete, 1} end