Files
music_library/backlog/tasks/ml-14 - Replace-Process.sleep-with-sys.get_state-in-error_notifier_test.exs.md
T
2026-04-20 10:02:25 +01:00

1.4 KiB

id, title, status, assignee, created_date, labels, dependencies, references, priority
id title status assignee created_date labels dependencies references priority
ML-14 Replace Process.sleep with :sys.get_state in error_notifier_test.exs Done
2026-04-20 08:50
https://github.com/cloud8421/music_library/issues/169
low

Description

GitHub: created 2026-04-16 · updated 2026-04-17 · closed 2026-04-17

Summary

Five Process.sleep(50) calls in test/error_tracker/error_notifier_test.exs wait for a GenServer to process a telemetry event before assert_email_sent. The sleeps are redundant and are the only timing-based waits in the suite.

Evidence

test/error_tracker/error_notifier_test.exs lines: :126, :136, :155, :164, :183

Each call is after :telemetry.execute/3, waiting for the ErrorTracker.ErrorNotifier GenServer to process the cast and call the mailer.

Fix

Replace each Process.sleep(50) with :sys.get_state(ErrorTracker.ErrorNotifier) — a synchronous probe that blocks until the GenServer has drained its mailbox up to the current message. Deterministic and faster.

Acceptance Criteria

  • Zero Process.sleep occurrences in test/
  • Tests remain deterministic and pass under repeated runs
  • #1 Zero Process.sleep occurrences in test/
  • #2 Tests remain deterministic and pass under repeated runs