Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
851B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.PingTest do
  5. use Pleroma.DataCase
  6. import Pleroma.Factory
  7. alias Pleroma.Web.Streamer
  8. setup do
  9. start_supervised({Streamer.supervisor(), [ping_interval: 30]})
  10. :ok
  11. end
  12. describe "sockets" do
  13. setup do
  14. user = insert(:user)
  15. {:ok, %{user: user}}
  16. end
  17. test "it sends pings", %{user: user} do
  18. task =
  19. Task.async(fn ->
  20. assert_receive {:text, received_event}, 40
  21. assert_receive {:text, received_event}, 40
  22. assert_receive {:text, received_event}, 40
  23. end)
  24. Streamer.add_socket("public", %{transport_pid: task.pid, assigns: %{user: user}})
  25. Task.await(task)
  26. end
  27. end
  28. end