From 156c5c8554ff41dde82a53c0fbc706384b88790d Mon Sep 17 00:00:00 2001 From: Parker Selbert Date: Thu, 14 Mar 2024 17:14:04 +0000 Subject: [PATCH] Prevent sonar from starting in test modes Sonar has no purpose during tests, and it can cause sandbox issues when tests run with the Postgres notifier. --- lib/oban/sonar.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/oban/sonar.ex b/lib/oban/sonar.ex index 4cbfe804..434dcb2c 100644 --- a/lib/oban/sonar.ex +++ b/lib/oban/sonar.ex @@ -19,7 +19,13 @@ defmodule Oban.Sonar do def start_link(opts) do {name, opts} = Keyword.pop(opts, :name) - GenServer.start_link(__MODULE__, struct!(State, opts), name: name) + conf = Keyword.fetch!(opts, :conf) + + if conf.testing != :disabled do + :ignore + else + GenServer.start_link(__MODULE__, struct!(State, opts), name: name) + end end @impl GenServer