Skip to content

Commit dc0288e

Browse files
committed
test that debug does not send message
1 parent da05828 commit dc0288e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/logger_backend_test.exs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,31 @@ defmodule Sentry.LoggerBackendTest do
345345
Logger.configure_backend(Sentry.LoggerBackend, level: :error, capture_log_messages: false)
346346
end
347347

348+
test "does not send debug messages when configured to :error" do
349+
Logger.configure_backend(Sentry.LoggerBackend, capture_log_messages: true)
350+
bypass = Bypass.open()
351+
modify_env(:sentry, dsn: "http://public:secret@localhost:#{bypass.port}/1")
352+
pid = self()
353+
354+
Bypass.expect_once(bypass, fn conn ->
355+
{:ok, body, conn} = Plug.Conn.read_body(conn)
356+
json = Jason.decode!(body)
357+
assert json["message"] == "error"
358+
send(pid, "API called")
359+
Plug.Conn.resp(conn, 200, ~s<{"id": "340"}>)
360+
end)
361+
362+
capture_log(fn ->
363+
Sentry.Context.set_user_context(%{user_id: 3})
364+
Logger.error("error")
365+
Logger.debug("debug")
366+
assert_receive("API called")
367+
refute_receive("API called")
368+
end)
369+
after
370+
Logger.configure_backend(Sentry.LoggerBackend, level: :error, capture_log_messages: false)
371+
end
372+
348373
# TODO: update for Elixir 1.10.4 to not manually set :callers and replace with Task
349374
test "sentry metadata is retrieved from callers" do
350375
Logger.configure_backend(Sentry.LoggerBackend, capture_log_messages: true)

0 commit comments

Comments
 (0)