diff --git a/test/microwaveprop/canopy/bulk_fetch_test.exs b/test/microwaveprop/canopy/bulk_fetch_test.exs new file mode 100644 index 00000000..ea0b0eb6 --- /dev/null +++ b/test/microwaveprop/canopy/bulk_fetch_test.exs @@ -0,0 +1,52 @@ +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 diff --git a/test/microwaveprop/prom_ex_test.exs b/test/microwaveprop/prom_ex_test.exs new file mode 100644 index 00000000..aec50ae0 --- /dev/null +++ b/test/microwaveprop/prom_ex_test.exs @@ -0,0 +1,19 @@ +defmodule Microwaveprop.PromExTest do + use ExUnit.Case, async: true + + describe "dashboards/0" do + test "returns the configured dashboard list" do + dashboards = Microwaveprop.PromEx.dashboards() + assert is_list(dashboards) + assert {:prom_ex, "application.json"} in dashboards + end + end + + describe "plugins/0" do + test "returns a non-empty plugin list" do + plugins = Microwaveprop.PromEx.plugins() + assert is_list(plugins) + assert plugins != [] + end + end +end diff --git a/test/microwaveprop/propagation/score_cache_test.exs b/test/microwaveprop/propagation/score_cache_test.exs index b71e9226..a9eb8f66 100644 --- a/test/microwaveprop/propagation/score_cache_test.exs +++ b/test/microwaveprop/propagation/score_cache_test.exs @@ -221,6 +221,13 @@ defmodule Microwaveprop.Propagation.ScoreCacheTest do end end + describe "max_entries/0" do + test "returns the configured cap as a positive integer" do + assert is_integer(ScoreCache.max_entries()) + assert ScoreCache.max_entries() > 0 + end + end + describe "max-entries eviction" do test "caps entries at max_entries, evicting the oldest valid_time" do cap = ScoreCache.max_entries()