prop/test/microwaveprop/canopy/bulk_fetch_test.exs
Graham McIntire 99103e5cd6
test: PromEx + Canopy.BulkFetch + Maidenhead.valid? coverage
- PromEx: added dashboards/0 + plugins/0 tests
- Canopy.BulkFetch: 0% -> covers run/4 entry path (all tile fetches fail
  cleanly without network); cache/staging dirs created
- Maidenhead.valid?/1: rejects integer/atom/tuple/list/map inputs
- Canopy.tile_filename/2: S/E hemisphere prefix branches
- ScoreCache.max_entries/0 invariant test

3624 tests, 0 failures.
2026-05-08 10:06:36 -05:00

52 lines
1.6 KiB
Elixir

defmodule Microwaveprop.Canopy.BulkFetchTest do
use ExUnit.Case, async: false
import ExUnit.CaptureLog
alias Microwaveprop.Canopy.BulkFetch
setup do
cache_dir = Path.join(System.tmp_dir!(), "canopy_test_#{System.unique_integer([:positive])}")
staging_dir = Path.join(System.tmp_dir!(), "canopy_staging_test_#{System.unique_integer([:positive])}")
on_exit(fn ->
File.rm_rf!(cache_dir)
File.rm_rf!(staging_dir)
end)
%{cache_dir: cache_dir, staging_dir: staging_dir}
end
describe "run/4" do
test "computes degree tiles and reports zero counters when COG fetch fails", %{
cache_dir: cache_dir,
staging_dir: staging_dir
} do
# The default ETH cog URL won't be reachable from the test sandbox,
# so the per-COG ensure step fails and increments the failed counter
# for every degree tile. We just verify run/4 returns a counter map
# with the expected keys and never crashes.
capture_log(fn ->
result = BulkFetch.run(32.5, -97.0, 1, cache_dir: cache_dir, staging_dir: staging_dir)
send(self(), result)
end)
assert_received %{
downloaded: _,
sliced: _,
cached: _,
failed: _,
cache_dir: ^cache_dir
}
end
test "creates the cache + staging directories", %{cache_dir: cache_dir, staging_dir: staging_dir} do
capture_log(fn ->
_ = BulkFetch.run(32.5, -97.0, 1, cache_dir: cache_dir, staging_dir: staging_dir)
end)
assert File.dir?(cache_dir)
assert File.dir?(staging_dir)
end
end
end