From 8057acf951f94b7ee0fa3b306654026310569d9b Mon Sep 17 00:00:00 2001 From: Benjamin Milde Date: Sun, 1 Dec 2024 17:10:55 +0100 Subject: [PATCH] Link module documentation of `leave` and `close` crashing the test process (#5803) --- lib/phoenix/test/channel_test.ex | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/phoenix/test/channel_test.ex b/lib/phoenix/test/channel_test.ex index 4ca2ccc997..ca78b799bc 100644 --- a/lib/phoenix/test/channel_test.ex +++ b/lib/phoenix/test/channel_test.ex @@ -223,7 +223,7 @@ defmodule Phoenix.ChannelTest do test "connect in a task" do pid = self() - task = Task.async(fn -> + task = Task.async(fn -> socket = socket(MyApp.UserSocket, "user_id", %{some: :assign}, test_process: pid) broadcast_from!(socket, "default", %{"foo" => "bar"}) assert_push "default", %{"foo" => "bar"} @@ -478,6 +478,10 @@ defmodule Phoenix.ChannelTest do @doc """ Emulates the client leaving the channel. + + By default this will crash the test process. Run + `Process.unlink(socket.channel_pid)` before this to prevent + this from happening. See [Leave and close](#module-leave-and-close). """ @spec leave(Socket.t) :: reference() def leave(%Socket{} = socket) do @@ -487,6 +491,10 @@ defmodule Phoenix.ChannelTest do @doc """ Emulates the client closing the socket. + By default this will crash the test process. Run + `Process.unlink(socket.channel_pid)` before this to prevent + this from happening. See [Leave and close](#module-leave-and-close). + Closing socket is synchronous and has a default timeout of 5000 milliseconds. """