Skip to content

Commit 49a159c

Browse files
committed
add test for malformed callers
1 parent dc0288e commit 49a159c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/logger_backend_test.exs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,26 @@ defmodule Sentry.LoggerBackendTest do
397397
assert_receive("API called")
398398
end)
399399
end
400+
401+
test "handles malformed :callers metadata" do
402+
Logger.configure_backend(Sentry.LoggerBackend, capture_log_messages: true)
403+
bypass = Bypass.open()
404+
modify_env(:sentry, dsn: "http://public:secret@localhost:#{bypass.port}/1")
405+
pid = self()
406+
{:ok, dead_pid} = Task.start(fn -> nil end)
407+
408+
Bypass.expect_once(bypass, fn conn ->
409+
{:ok, body, conn} = Plug.Conn.read_body(conn)
410+
json = Jason.decode!(body)
411+
assert json["message"] == "error"
412+
send(pid, "API called")
413+
Plug.Conn.resp(conn, 200, ~s<{"id": "340"}>)
414+
end)
415+
416+
capture_log(fn ->
417+
Logger.error("error", callers: [dead_pid, nil])
418+
419+
assert_receive("API called")
420+
end)
421+
end
400422
end

0 commit comments

Comments
 (0)