From 32818d58663cc02297ca251febac436c5c94c0e4 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 5 Aug 2026 08:28:50 -0500 Subject: [PATCH] fix: repair mix test by removing forced MIX_ENV=dev and silencing test noise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - nix/shell.nix: remove export MIX_ENV=dev — it overrode Mix's automatic env selection, causing mix test to load dev config with no sandbox pool - config/runtime.exs: use Ecto.Adapters.SQL.Sandbox pool (not DBConnection.Ownership) for test env — test_helper.exs uses the Sandbox API which requires the sandbox pool type - test/test_helper.exs: silence NarrFetchWorker and ObanErrorReporter log noise at :critical level — expected error-path output when inline Oban jobs hit stubbed HTTP 500s --- config/runtime.exs | 2 +- nix/shell.nix | 4 ++-- test/test_helper.exs | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/config/runtime.exs b/config/runtime.exs index 7b7bf1a5..d7c5492c 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -13,7 +13,7 @@ require Logger if config_env() == :test do for repo <- [Microwaveprop.Repo] do existing = Application.get_env(:microwaveprop, repo, []) - Application.put_env(:microwaveprop, repo, Keyword.put(existing, :pool, DBConnection.Ownership)) + Application.put_env(:microwaveprop, repo, Keyword.put(existing, :pool, Ecto.Adapters.SQL.Sandbox)) end end diff --git a/nix/shell.nix b/nix/shell.nix index 3aaae63c..9bae14d3 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -229,8 +229,8 @@ mkShell { export SECRET_KEY_BASE="dev_secret_key_base_at_least_64_bytes_long_for_phoenix_to_accept_it_safely" export RELEASE_COOKIE="dev_release_cookie_for_distributed_erlang" - # Development environment - export MIX_ENV=dev + # Mix defaults to :dev for most tasks and :test for mix test; + # don't force MIX_ENV — let Mix select automatically. export PHX_HOST=localhost export PORT=4000 diff --git a/test/test_helper.exs b/test/test_helper.exs index f3f0d2c2..06eaa676 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -67,6 +67,15 @@ Logger.put_module_level( :critical ) +# Silence expected error-path noise during tests. Background workers +# (NarrFetch, etc.) run inline under `testing: :inline` and hit stubbed +# HTTP 500 responses — the warnings and Oban job-exception logs are +# deliberate test behaviour, not bugs. +Logger.put_module_level( + [Microwaveprop.Workers.NarrFetchWorker, Microwaveprop.ObanErrorReporter], + :critical +) + if Code.ensure_loaded?(Mox) do Mox.defmock(Microwaveprop.Valkey.MockAdapter, for: Microwaveprop.Valkey.Adapter) end