From f9553b1444cd751a565a780ecdf097cfb9121a31 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 20 Jan 2026 13:48:13 -0600 Subject: [PATCH] Fix flaky tests in MonitoringSupervisor and AlertNotifier - Add Mox stub setup in supervisor_test.exs to handle DeviceMonitor ping calls - Change alert_notifier_test.exs to async: true to prevent mailbox contamination - All 1066 tests now passing with 0 failures --- test/towerops/alerts/alert_notifier_test.exs | 2 +- test/towerops/monitoring/supervisor_test.exs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/towerops/alerts/alert_notifier_test.exs b/test/towerops/alerts/alert_notifier_test.exs index 0cf11b1d..8f96f56b 100644 --- a/test/towerops/alerts/alert_notifier_test.exs +++ b/test/towerops/alerts/alert_notifier_test.exs @@ -1,5 +1,5 @@ defmodule Towerops.Alerts.AlertNotifierTest do - use Towerops.DataCase, async: false + use Towerops.DataCase, async: true import Swoosh.TestAssertions import Towerops.AccountsFixtures diff --git a/test/towerops/monitoring/supervisor_test.exs b/test/towerops/monitoring/supervisor_test.exs index d755b9b2..530a8792 100644 --- a/test/towerops/monitoring/supervisor_test.exs +++ b/test/towerops/monitoring/supervisor_test.exs @@ -1,12 +1,19 @@ defmodule Towerops.Monitoring.SupervisorTest do use Towerops.DataCase, async: false + import Mox import Towerops.AccountsFixtures + alias Towerops.Monitoring.PingMock alias Towerops.Monitoring.Supervisor, as: MonitoringSupervisor alias Towerops.Snmp.PollerRegistry + setup :verify_on_exit! + setup do + # Stub ping calls for any monitors that start during tests + # Allow any number of ping calls (monitors ping on init) + stub_with(PingMock, Towerops.Monitoring.PingStub) # Start Monitoring.Supervisor for these tests start_supervised!(MonitoringSupervisor)