diff options
author | rinpatch <rinpatch@sdf.org> | 2019-06-16 10:33:25 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-06-16 10:33:25 +0000 |
commit | efa445a75b242787a30ffbc2eb16bd165260f66c (patch) | |
tree | 8573c525a0c2b2ddf3e6b49870cd413de81b51f0 /test/web | |
parent | 57d54a9f095774d856b7966c5fbc08c27fbdd586 (diff) | |
parent | a04bf131e052f12c82e09b22c5e942e99c36d0ee (diff) | |
download | pleroma-efa445a75b242787a30ffbc2eb16bd165260f66c.tar.gz |
Merge branch 'issues/570' into 'develop'
[#570] add user:notification stream
See merge request pleroma/pleroma!1274
Diffstat (limited to 'test/web')
-rw-r--r-- | test/web/streamer_test.exs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/web/streamer_test.exs b/test/web/streamer_test.exs index c18b9f9fe..648e28712 100644 --- a/test/web/streamer_test.exs +++ b/test/web/streamer_test.exs @@ -21,6 +21,52 @@ defmodule Pleroma.Web.StreamerTest do :ok end + describe "user streams" do + setup do + GenServer.start(Streamer, %{}, name: Streamer) + + on_exit(fn -> + if pid = Process.whereis(Streamer) do + Process.exit(pid, :kill) + end + end) + + user = insert(:user) + notify = insert(:notification, user: user, activity: build(:note_activity)) + {:ok, %{user: user, notify: notify}} + end + + test "it sends notify to in the 'user' stream", %{user: user, notify: notify} do + task = + Task.async(fn -> + assert_receive {:text, _}, 4_000 + end) + + Streamer.add_socket( + "user", + %{transport_pid: task.pid, assigns: %{user: user}} + ) + + Streamer.stream("user", notify) + Task.await(task) + end + + test "it sends notify to in the 'user:notification' stream", %{user: user, notify: notify} do + task = + Task.async(fn -> + assert_receive {:text, _}, 4_000 + end) + + Streamer.add_socket( + "user:notification", + %{transport_pid: task.pid, assigns: %{user: user}} + ) + + Streamer.stream("user:notification", notify) + Task.await(task) + end + end + test "it sends to public" do user = insert(:user) other_user = insert(:user) |