Fix notification skipping
This commit is contained in:
@@ -30,7 +30,7 @@ defmodule ErrorTracker.ErrorNotifier do
|
|||||||
reason = truncate_reason(metadata.occurrence.reason)
|
reason = truncate_reason(metadata.occurrence.reason)
|
||||||
|
|
||||||
{_result, new_state} =
|
{_result, new_state} =
|
||||||
maybe_notify(metadata.occurrence, metadata.error.muted, "New Error! (#{reason})", state)
|
maybe_notify(metadata.occurrence, false, "New Error! (#{reason})", state)
|
||||||
|
|
||||||
{:noreply, new_state}
|
{:noreply, new_state}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ defmodule ErrorTracker.ErrorNotifier do
|
|||||||
reason = truncate_reason(metadata.occurrence.reason)
|
reason = truncate_reason(metadata.occurrence.reason)
|
||||||
|
|
||||||
{_result, new_state} =
|
{_result, new_state} =
|
||||||
maybe_notify(metadata.occurrence, metadata.error.muted, "Error: #{reason}", state)
|
maybe_notify(metadata.occurrence, metadata.muted, "Error: #{reason}", state)
|
||||||
|
|
||||||
{:noreply, new_state}
|
{:noreply, new_state}
|
||||||
|
|
||||||
|
|||||||
@@ -124,8 +124,9 @@ defmodule ErrorTracker.ErrorNotifierTest do
|
|||||||
|
|
||||||
# Second notification for same error: throttled
|
# Second notification for same error: throttled
|
||||||
:telemetry.execute([:error_tracker, :occurrence, :new], %{}, %{
|
:telemetry.execute([:error_tracker, :occurrence, :new], %{}, %{
|
||||||
error: %ErrorTracker.Error{id: 1},
|
error: %Error{id: 1},
|
||||||
occurrence: occurrence(%{error_id: 1})
|
occurrence: occurrence(%{error_id: 1}),
|
||||||
|
muted: false
|
||||||
})
|
})
|
||||||
|
|
||||||
Process.sleep(50)
|
Process.sleep(50)
|
||||||
@@ -138,13 +139,24 @@ defmodule ErrorTracker.ErrorNotifierTest do
|
|||||||
describe "skipping" do
|
describe "skipping" do
|
||||||
test "skips notification when error is muted" do
|
test "skips notification when error is muted" do
|
||||||
Application.put_env(:music_library, ErrorNotifier, @config)
|
Application.put_env(:music_library, ErrorNotifier, @config)
|
||||||
|
|
||||||
{:ok, pid} = ErrorNotifier.start_link([])
|
{:ok, pid} = ErrorNotifier.start_link([])
|
||||||
|
|
||||||
:telemetry.execute([:error_tracker, :error, :new], %{}, %{
|
:telemetry.execute([:error_tracker, :error, :new], %{}, %{
|
||||||
error: %Error{id: 1, muted: true},
|
error: %Error{id: 1},
|
||||||
occurrence: occurrence(%{error_id: 1})
|
occurrence: occurrence(%{error_id: 1})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Process.sleep(50)
|
||||||
|
assert_email_sent()
|
||||||
|
|
||||||
|
:telemetry.execute([:error_tracker, :occurrence, :new], %{}, %{
|
||||||
|
error: %Error{id: 2},
|
||||||
|
occurrence: occurrence(%{error_id: 2}),
|
||||||
|
muted: true
|
||||||
|
})
|
||||||
|
|
||||||
|
Process.sleep(50)
|
||||||
refute_email_sent()
|
refute_email_sent()
|
||||||
|
|
||||||
GenServer.stop(pid)
|
GenServer.stop(pid)
|
||||||
|
|||||||
Reference in New Issue
Block a user