fix: repair mix test by removing forced MIX_ENV=dev and silencing test noise
Some checks failed
Build and Push / Build and Push Docker Image (push) Has been cancelled

- 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
This commit is contained in:
Graham McIntire 2026-08-05 08:28:50 -05:00
parent 4533acd41d
commit 32818d5866
3 changed files with 12 additions and 3 deletions

View file

@ -13,7 +13,7 @@ require Logger
if config_env() == :test do if config_env() == :test do
for repo <- [Microwaveprop.Repo] do for repo <- [Microwaveprop.Repo] do
existing = Application.get_env(:microwaveprop, repo, []) 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
end end

View file

@ -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 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" export RELEASE_COOKIE="dev_release_cookie_for_distributed_erlang"
# Development environment # Mix defaults to :dev for most tasks and :test for mix test;
export MIX_ENV=dev # don't force MIX_ENV — let Mix select automatically.
export PHX_HOST=localhost export PHX_HOST=localhost
export PORT=4000 export PORT=4000

View file

@ -67,6 +67,15 @@ Logger.put_module_level(
:critical :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 if Code.ensure_loaded?(Mox) do
Mox.defmock(Microwaveprop.Valkey.MockAdapter, for: Microwaveprop.Valkey.Adapter) Mox.defmock(Microwaveprop.Valkey.MockAdapter, for: Microwaveprop.Valkey.Adapter)
end end