Replace Process.sleep with sys.get_state in error notifier tests

Deterministic GenServer state polling instead of timing-based waits.
Fixes #169.
This commit is contained in:
Claudio Ortolina
2026-04-17 12:58:50 +01:00
parent e6a8488137
commit d8d5524e41
+5 -5
View File
@@ -123,7 +123,7 @@ defmodule ErrorTracker.ErrorNotifierTest do
occurrence: occurrence(%{error_id: 1}) occurrence: occurrence(%{error_id: 1})
}) })
Process.sleep(50) :sys.get_state(ErrorNotifier)
assert_email_sent() assert_email_sent()
# Second notification for same error: throttled # Second notification for same error: throttled
@@ -133,7 +133,7 @@ defmodule ErrorTracker.ErrorNotifierTest do
muted: false muted: false
}) })
Process.sleep(50) :sys.get_state(ErrorNotifier)
refute_email_sent() refute_email_sent()
GenServer.stop(pid) GenServer.stop(pid)
@@ -152,7 +152,7 @@ defmodule ErrorTracker.ErrorNotifierTest do
occurrence: occurrence(%{error_id: 1}) occurrence: occurrence(%{error_id: 1})
}) })
Process.sleep(50) :sys.get_state(ErrorNotifier)
assert_email_sent() assert_email_sent()
:telemetry.execute([:error_tracker, :occurrence, :new], %{}, %{ :telemetry.execute([:error_tracker, :occurrence, :new], %{}, %{
@@ -161,7 +161,7 @@ defmodule ErrorTracker.ErrorNotifierTest do
muted: true muted: true
}) })
Process.sleep(50) :sys.get_state(ErrorNotifier)
refute_email_sent() refute_email_sent()
GenServer.stop(pid) GenServer.stop(pid)
@@ -180,7 +180,7 @@ defmodule ErrorTracker.ErrorNotifierTest do
occurrence: occurrence(%{error_id: 99}) occurrence: occurrence(%{error_id: 99})
}) })
Process.sleep(50) :sys.get_state(ErrorNotifier)
assert_email_sent(subject: ~r/MusicLibrary/) assert_email_sent(subject: ~r/MusicLibrary/)
GenServer.stop(pid) GenServer.stop(pid)