Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Prevent Salts server from dirty postgres disconnects during tests (#5968)
Adam Rutkowski6d72c183d248
diff --git a/test/support/conn_case.ex b/test/support/conn_case.exindex 1a0565ee8f..99432208bf 100644--- a/test/support/conn_case.ex+++ b/test/support/conn_case.ex@@ -40,6 +40,8 @@ defmodule PlausibleWeb.ConnCase doEcto.Adapters.SQL.Sandbox.mode(Plausible.Repo, {:shared, self()})end+ Plausible.Test.Support.Sandbox.allow_salts_process()+# randomize client ip to avoid accidentally hitting# rate limiting during testsconn =diff --git a/test/support/data_case.ex b/test/support/data_case.exindex 54fc41685a..e379994e68 100644--- a/test/support/data_case.ex+++ b/test/support/data_case.ex@@ -37,6 +37,8 @@ defmodule Plausible.DataCase doEcto.Adapters.SQL.Sandbox.mode(Plausible.Repo, {:shared, self()})end+ Plausible.Test.Support.Sandbox.allow_salts_process()+:okendenddiff --git a/test/support/plugins_api_case.ex b/test/support/plugins_api_case.exindex 6eab811344..f0eec2e631 100644--- a/test/support/plugins_api_case.ex+++ b/test/support/plugins_api_case.ex@@ -41,6 +41,8 @@ defmodule PlausibleWeb.PluginsAPICase doEcto.Adapters.SQL.Sandbox.mode(Plausible.Repo, {:shared, self()})end+ Plausible.Test.Support.Sandbox.allow_salts_process()+conn = Phoenix.ConnTest.build_conn()site = Plausible.Teams.Test.new_site()diff --git a/test/support/sandbox.ex b/test/support/sandbox.exnew file mode 100644index 0000000000..1c75890a3a--- /dev/null+++ b/test/support/sandbox.ex@@ -0,0 +1,15 @@+defmodule Plausible.Test.Support.Sandbox do+ @moduledoc """+ Prevent background processes from interfering with tests+ (e.g. exiting before properly returning the connection) by allowing them to access sandbox+ """+ def allow_salts_process do+ case Process.whereis(Plausible.Session.Salts) do+ nil ->+ :ok++ pid ->+ Ecto.Adapters.SQL.Sandbox.allow(Plausible.Repo, self(), pid)+ end+ end+end