From 680ffa8cf23803fbb72c794297146671f8f642b3 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 8 May 2026 10:43:51 -0500 Subject: [PATCH] test: silence Postgrex sandbox disconnect noise When a test process exits while still owning a sandboxed Postgrex connection, Postgrex.Protocol logs `[error] ... disconnected: DBConnection.ConnectionError client #PID<...> exited`. It's benign sandbox cleanup but at :error level it bypasses `capture_log: true` (which only captures the test process's logs) and clutters every test run. Pin Postgrex.Protocol + DBConnection.Connection to :critical so the noise drops without masking genuine DB error reporting (we never log at :critical from those modules). --- test/test_helper.exs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_helper.exs b/test/test_helper.exs index 7db213e5..fe115e04 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -4,4 +4,16 @@ ExUnit.start(capture_log: true) Sandbox.mode(Microwaveprop.Repo, :manual) Sandbox.mode(Microwaveprop.AprsRepo, :manual) +# Silence sandbox-cleanup disconnect noise. When a test process exits +# while still owning a Postgrex connection, the protocol logs an +# `[error] Postgrex.Protocol ... disconnected: ... client #PID<...> +# exited`. It's benign — the connection is being torn down on purpose +# — but at :error level it bypasses `capture_log: true` (which only +# captures logs from the test process). Pinning these modules to +# :critical drops the noise without affecting real DB error logging. +Logger.put_module_level( + [Postgrex.Protocol, DBConnection.Connection], + :critical +) + Mox.defmock(Microwaveprop.Valkey.MockAdapter, for: Microwaveprop.Valkey.Adapter)