Fix BackfillEnqueueWorker test timeouts and credo length warnings

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.
This commit is contained in:
Graham McIntire 2026-04-12 15:02:38 -05:00
parent 20623f9ebf
commit a6a71e8c94
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
2 changed files with 23 additions and 6 deletions

View file

@ -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

View file

@ -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