Add test to cover error: bad_topic

This commit is contained in:
tusooa 2023-04-01 08:39:38 -04:00
parent eebc605bc2
commit 050227f118
No known key found for this signature in database
GPG Key ID: 42AEC43D48433C51
1 changed files with 12 additions and 0 deletions

View File

@ -180,6 +180,18 @@ test "won't double subscribe" do
refute_receive {:text, _}, 1_000 refute_receive {:text, _}, 1_000
end end
test "rejects invalid streams" do
{:ok, pid} = start_socket()
WebsocketClient.send_text(pid, %{type: "subscribe", stream: "nonsense"} |> Jason.encode!())
assert_receive {:text, raw_json}, 1_000
assert {:ok,
%{
"event" => "pleroma:respond",
"payload" => %{"type" => "subscribe", "result" => "error", "error" => "bad_topic"}
}} = decode_json(raw_json)
end
test "can unsubscribe" do test "can unsubscribe" do
user = insert(:user) user = insert(:user)
{:ok, pid} = start_socket() {:ok, pid} = start_socket()