Skip to content

Commit 4e0e12c

Browse files
committed
add failing test
1 parent aaf6f4a commit 4e0e12c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/logger_test.exs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,32 @@ defmodule Sentry.LoggerTest do
110110
end
111111
:error_logger.delete_report_handler(Sentry.Logger)
112112
end
113+
114+
test "error_logger passes context properly" do
115+
bypass = Bypass.open
116+
pid = self()
117+
Bypass.expect bypass, fn conn ->
118+
{:ok, body, conn} = Plug.Conn.read_body(conn)
119+
body = Poison.decode!(body)
120+
assert get_in(body, ["extra", "fruit"]) == "apples"
121+
assert conn.request_path == "/api/1/store/"
122+
assert conn.method == "POST"
123+
send(pid, "API called")
124+
Plug.Conn.resp(conn, 200, ~s<{"id": "340"}>)
125+
end
126+
127+
modify_env(:sentry, dsn: "http://public:secret@localhost:#{bypass.port}/1")
128+
:error_logger.add_report_handler(Sentry.Logger)
129+
130+
capture_log fn ->
131+
Task.start( fn ->
132+
Sentry.Context.set_extra_context(%{fruit: "apples"})
133+
raise "Unique Error"
134+
end)
135+
136+
assert_receive "API called"
137+
end
138+
139+
:error_logger.delete_report_handler(Sentry.Logger)
140+
end
113141
end

0 commit comments

Comments
 (0)