Skip to content

Commit

Permalink
fix accumulated_occurrences reset before notify
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinco committed Aug 23, 2024
1 parent 5eac749 commit e5c7693
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/boom_notifier/notification_sender.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ defmodule BoomNotifier.NotificationSender do

def notify_all(settings, error_info) do
notification_trigger = Keyword.get(settings, :notification_trigger, :always)
ErrorStorage.reset_accumulated_errors(notification_trigger, error_info)

occurrences = Map.put(error_info, :occurrences, ErrorStorage.get_error_stats(error_info))

ErrorStorage.reset_accumulated_errors(notification_trigger, error_info)

BoomNotifier.Api.walkthrough_notifiers(
settings,
fn notifier, options -> notify(notifier, occurrences, options) end
Expand Down
8 changes: 8 additions & 0 deletions test/unit/notification_sender_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ defmodule BoomNotifier.NotificationSenderTest do
refute_receive({:notify_called, _}, @receive_timeout)
assert {:schedule, @throttle_timeout} = trigger_notify_resp
end

test "sends notification occurrences along error info", %{error_info: error_info} do
for _ <- 1..7 do
NotificationSender.trigger_notify(@settings_groupping, error_info)
end

assert_receive({:notify_called, %{occurrences: %{accumulated_occurrences: 4}}})
end
end

describe "async call with exponential notification trigger" do
Expand Down

0 comments on commit e5c7693

Please sign in to comment.