defmodule Microwaveprop.Workers.PartitionMaintenanceWorkerTest do use Microwaveprop.DataCase, async: true use Oban.Testing, repo: Microwaveprop.Repo alias Microwaveprop.Workers.PartitionMaintenanceWorker describe "perform/1" do test "returns :ok with default args against the real partitioned tables" do # The test DB ships with hrrr_profiles + hrdps_profiles partitions # well into 2027 (some of them half-year-wide), so a default # lookahead pass should be a complete no-op. The coverage check # in PartitionManager.ensure_partition/3 is what makes that # safe — without it, this call would try to CREATE a quarterly # partition that overlaps an existing half-year one and crash. assert :ok = perform_job(PartitionMaintenanceWorker, %{}) end test "respects lookahead_quarters override" do assert :ok = perform_job(PartitionMaintenanceWorker, %{"lookahead_quarters" => 0}) end test "rejects negative lookahead at the worker boundary" do # Worker falls through to default when args don't match the # is_integer + >= 0 guard, so a bogus arg still succeeds. assert :ok = perform_job(PartitionMaintenanceWorker, %{"lookahead_quarters" => -1}) end end end