test: silence expected warnings/errors during test runs
Passes `capture_log: true` to ExUnit.start/1 so log output emitted
during a passing test stays in the per-test capture buffer instead of
stdout. Drops ~360 lines of noise from the suite: Postgrex teardown
disconnects, expected worker failures, NexradClient 404 stubs,
NotifyListener warm-skip messages, SNMP poll failures, PromEx tag-
drop warnings, and OTel-handler boot errors. Failing tests still
surface their full logs on report, so debugging is unchanged.
Side-effect fixes:
- LoggerFormatTest opts out via @moduletag capture_log: false — it
patches the :default :logger handler and capture_log hot-swaps the
same handler, so the setup lookup would 404.
- TelemetryTest.start_link/1 unlinks the supervisor before the brutal
kill so the exit signal doesn't propagate to the test process.
- Drop unused `import Ecto.Query` in a top_hours mix-task test.
- Drop unused default-arg `attrs \\ %{}` on create_contact/1 in
contact_map_live_test (every caller passes attrs explicitly).
Remaining noise is ~3 lines from oban_pro vendored-dep @impl warnings
(require an upstream patch) plus rare intermittent async teardowns.
This commit is contained in:
parent
b057b45fe7
commit
b2b8ddc1c4
5 changed files with 12 additions and 6 deletions
|
|
@ -2,12 +2,18 @@ defmodule Microwaveprop.LoggerFormatTest do
|
|||
# async: false — we briefly swap the global :default :logger handler's
|
||||
# formatter and forward its output to a self()-bound IO device so the
|
||||
# test can capture the JSON-encoded output. Restored on exit.
|
||||
#
|
||||
# Opts out of the suite-wide capture_log flag — capture_log hot-swaps
|
||||
# the :default handler for its own capture handler, so our direct
|
||||
# :logger.get_handler_config(:default) lookup in setup would 404.
|
||||
use ExUnit.Case, async: false
|
||||
|
||||
alias LoggerJSON.Formatters.Basic
|
||||
|
||||
require Logger
|
||||
|
||||
@moduletag capture_log: false
|
||||
|
||||
describe "structured JSON formatter" do
|
||||
setup do
|
||||
{:ok, handler_cfg} = :logger.get_handler_config(:default)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ defmodule MicrowavepropWeb.ContactMapLiveTest do
|
|||
alias Microwaveprop.Radio.Contact
|
||||
alias Microwaveprop.Repo
|
||||
|
||||
defp create_contact(attrs \\ %{}) do
|
||||
defp create_contact(attrs) do
|
||||
default = %{
|
||||
station1: "W5XD",
|
||||
station2: "K5TR",
|
||||
|
|
|
|||
|
|
@ -93,8 +93,10 @@ defmodule MicrowavepropWeb.TelemetryTest do
|
|||
{:ok, pid} = Supervisor.start_link(Telemetry, :ok, name: sup_name)
|
||||
assert Process.alive?(pid)
|
||||
|
||||
on_exit = fn -> if Process.alive?(pid), do: Process.exit(pid, :kill) end
|
||||
on_exit.()
|
||||
# Unlink before tearing down so the brutal-kill exit signal doesn't
|
||||
# propagate to the test process (which trap_exit defaults to off).
|
||||
Process.unlink(pid)
|
||||
Process.exit(pid, :kill)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -118,8 +118,6 @@ defmodule Mix.Tasks.SimpleTasksTest do
|
|||
end
|
||||
|
||||
test "enqueues jobs for the top hours when contacts exist" do
|
||||
import Ecto.Query
|
||||
|
||||
# Seed one contact so top_hours_by_contact_count returns something.
|
||||
{:ok, _contact} =
|
||||
%Contact{}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
ExUnit.start(exclude: [:slow])
|
||||
ExUnit.start(exclude: [:slow], capture_log: true)
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Microwaveprop.Repo, :manual)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue