Skip to content

Commit

Permalink
change notification_trigger occurrences to count
Browse files Browse the repository at this point in the history
Fix test that was not detecting this
  • Loading branch information
joaquinco committed Nov 12, 2024
1 parent 9affdd3 commit 51cfb59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion test/unit/error_storage_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ defmodule ErrorStorageTest do
}
end

test "does not increase the counter when notification_trigger is :always" do
test "does not increase the counter when count is :always" do
ErrorStorage.accumulate(@error_info)

ErrorStorage.reset_stats(@error_info, :always)
Expand Down
16 changes: 7 additions & 9 deletions test/unit/notifier_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ defmodule NotifierTest do
defmodule PlugErrorWithExponentialTriggerNotifier do
use BoomNotifier,
notifier: FakeNotifier,
notification_trigger: :exponential,
count: :exponential,
options: [
subject: "BOOM error caught",
sender_pid_name: TestMessageProxy
Expand All @@ -132,7 +132,7 @@ defmodule NotifierTest do
defmodule PlugErrorWithExponentialTriggerWithLimitNotifier do
use BoomNotifier,
notifier: FakeNotifier,
notification_trigger: [exponential: [limit: 3]],
count: [exponential: [limit: 3]],
options: [
subject: "BOOM error caught",
sender_pid_name: TestMessageProxy
Expand Down Expand Up @@ -229,7 +229,7 @@ defmodule NotifierTest do
assert_receive(%{exception: %{subject: "BOOM error caught: thrown error"}}, @receive_timeout)
end

test "reports exception in groups when :notification_trigger setting is :exponential" do
test "reports exception in groups when :count setting is :exponential" do
conn = conn(:get, "/")

catch_error(PlugErrorWithExponentialTriggerNotifier.call(conn, []))
Expand All @@ -239,11 +239,10 @@ defmodule NotifierTest do
catch_error(PlugErrorWithExponentialTriggerNotifier.call(conn, []))
assert_receive(%{exception: _}, @receive_timeout)

{:message_queue_len, exceptions} = Process.info(self(), :message_queue_len)
assert exceptions == 0
refute_receive(%{exception: _}, @receive_timeout)
end

test "reports exception in groups when :notification_trigger setting is :exponential with limit" do
test "reports exception in groups when :count setting is :exponential with limit" do
conn = conn(:get, "/")

catch_error(PlugErrorWithExponentialTriggerWithLimitNotifier.call(conn, []))
Expand All @@ -263,11 +262,10 @@ defmodule NotifierTest do
catch_error(PlugErrorWithExponentialTriggerWithLimitNotifier.call(conn, []))
assert_receive(%{exception: _}, @receive_timeout)

{:message_queue_len, exceptions} = Process.info(self(), :message_queue_len)
assert exceptions == 0
refute_receive(%{exception: _}, @receive_timeout)
end

test "reports every exception when :notification_trigger setting is not set" do
test "reports every exception when :count setting is not set" do
conn = conn(:get, "/")

catch_error(PlugErrorWithSingleNotifier.call(conn, []))
Expand Down

0 comments on commit 51cfb59

Please sign in to comment.