1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.StateTest do
9 alias Pleroma.Web.Streamer
10 alias Pleroma.Web.Streamer.StreamerSocket
12 @moduletag needs_streamer: true
18 {:ok, %{user: user, user2: user2}}
21 test "it can add a socket", %{user: user} do
22 Streamer.add_socket("public", %{transport_pid: 1, assigns: %{user: user}})
24 assert(%{"public" => [%StreamerSocket{transport_pid: 1}]} = Streamer.get_sockets())
27 test "it can add multiple sockets per user", %{user: user} do
28 Streamer.add_socket("public", %{transport_pid: 1, assigns: %{user: user}})
29 Streamer.add_socket("public", %{transport_pid: 2, assigns: %{user: user}})
34 %StreamerSocket{transport_pid: 2},
35 %StreamerSocket{transport_pid: 1}
37 } = Streamer.get_sockets()
41 test "it will not add a duplicate socket", %{user: user} do
42 Streamer.add_socket("activity", %{transport_pid: 1, assigns: %{user: user}})
43 Streamer.add_socket("activity", %{transport_pid: 1, assigns: %{user: user}})
48 %StreamerSocket{transport_pid: 1}
50 } = Streamer.get_sockets()