From d8d5524e418a1f87bd4fbd1ac7eb56da49c3f409 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Fri, 17 Apr 2026 12:58:50 +0100 Subject: [PATCH] Replace Process.sleep with sys.get_state in error notifier tests Deterministic GenServer state polling instead of timing-based waits. Fixes #169. --- test/error_tracker/error_notifier_test.exs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/error_tracker/error_notifier_test.exs b/test/error_tracker/error_notifier_test.exs index 95299c44..47952f60 100644 --- a/test/error_tracker/error_notifier_test.exs +++ b/test/error_tracker/error_notifier_test.exs @@ -123,7 +123,7 @@ defmodule ErrorTracker.ErrorNotifierTest do occurrence: occurrence(%{error_id: 1}) }) - Process.sleep(50) + :sys.get_state(ErrorNotifier) assert_email_sent() # Second notification for same error: throttled @@ -133,7 +133,7 @@ defmodule ErrorTracker.ErrorNotifierTest do muted: false }) - Process.sleep(50) + :sys.get_state(ErrorNotifier) refute_email_sent() GenServer.stop(pid) @@ -152,7 +152,7 @@ defmodule ErrorTracker.ErrorNotifierTest do occurrence: occurrence(%{error_id: 1}) }) - Process.sleep(50) + :sys.get_state(ErrorNotifier) assert_email_sent() :telemetry.execute([:error_tracker, :occurrence, :new], %{}, %{ @@ -161,7 +161,7 @@ defmodule ErrorTracker.ErrorNotifierTest do muted: true }) - Process.sleep(50) + :sys.get_state(ErrorNotifier) refute_email_sent() GenServer.stop(pid) @@ -180,7 +180,7 @@ defmodule ErrorTracker.ErrorNotifierTest do occurrence: occurrence(%{error_id: 99}) }) - Process.sleep(50) + :sys.get_state(ErrorNotifier) assert_email_sent(subject: ~r/MusicLibrary/) GenServer.stop(pid)