Skip to content

Commit 8703c61

Browse files
fix test
1 parent 5c90d1d commit 8703c61

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test/phoenix/endpoint/endpoint_test.exs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,6 @@ defmodule Phoenix.Endpoint.EndpointTest do
311311
end
312312

313313
test "emits telemetry event on pubsub broadcast with multiple subscribers", ctx do
314-
# reset config
315-
Application.put_env(:phoenix, __MODULE__.Endpoint, @config)
316-
317314
me = self()
318315
:telemetry.attach(
319316
ctx.test,
@@ -324,17 +321,20 @@ defmodule Phoenix.Endpoint.EndpointTest do
324321
nil
325322
)
326323

327-
Endpoint.subscribe("multi_topic")
328-
Enum.each(1..2, fn _ ->
329-
spawn fn ->
330-
Endpoint.subscribe("multi_topic")
331-
Process.sleep(5000)
332-
:ok
333-
end
334-
end)
324+
Endpoint.subscribe("atopic")
325+
spawn fn ->
326+
Endpoint.subscribe("atopic")
327+
send(me, :subscribed)
328+
329+
Process.sleep(5000)
330+
:ok
331+
end
332+
333+
# makes sure that subscription in spawned process happens before broadcast
334+
assert_receive :subscribed
335335

336-
Endpoint.broadcast("multi_topic", "event1", %{key: :val})
337-
assert_receive {:telemetry, _, %{}, %{subscriber_count: 3, message: %{topic: "multi_topic", event: "event1", payload: %{key: :val}}}}
336+
Endpoint.broadcast("atopic", "event1", %{key: :val})
337+
assert_receive {:telemetry, _, %{}, %{subscriber_count: 2, message: %{topic: "atopic", event: "event1", payload: %{key: :val}}}}
338338
end
339339

340340
test "loads cache manifest from specified application" do

0 commit comments

Comments
 (0)