commit: 4a6b49d0b4529936b06a3f1668d937220fb2173b
parent 30943b739d8d7eefed94f13bc442d1fc348e2737
Author: feld <feld@feld.me>
Date: Mon, 7 Jun 2021 21:22:23 +0000
Merge branch 'fix/config-test-warning' into 'develop'
Fix test warnings
See merge request pleroma/pleroma!3452
Diffstat:
3 files changed, 61 insertions(+), 64 deletions(-)
diff --git a/test/pleroma/web/admin_api/controllers/config_controller_test.exs b/test/pleroma/web/admin_api/controllers/config_controller_test.exs
@@ -1427,30 +1427,27 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
]
}
- res =
- assert conn
- |> put_req_header("content-type", "application/json")
- |> post("/api/pleroma/admin/config", %{"configs" => [params]})
- |> json_response_and_validate_schema(200)
-
- assert res == %{
- "configs" => [
- %{
- "db" => [":instance_thumbnail"],
- "group" => ":pleroma",
- "key" => ":instance",
- "value" => params["value"]
- }
- ],
- "need_reboot" => false
- }
-
- _res =
- assert conn
- |> get("/api/v1/instance")
- |> json_response_and_validate_schema(200)
+ assert conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/pleroma/admin/config", %{"configs" => [params]})
+ |> json_response_and_validate_schema(200) ==
+ %{
+ "configs" => [
+ %{
+ "db" => [":instance_thumbnail"],
+ "group" => ":pleroma",
+ "key" => ":instance",
+ "value" => params["value"]
+ }
+ ],
+ "need_reboot" => false
+ }
- assert res = %{"thumbnail" => "https://example.com/media/new_thumbnail.jpg"}
+ assert conn
+ |> get("/api/v1/instance")
+ |> json_response_and_validate_schema(200)
+ |> Map.take(["thumbnail"]) ==
+ %{"thumbnail" => "https://example.com/media/new_thumbnail.jpg"}
end
test "Concurrent Limiter", %{conn: conn} do
diff --git a/test/pleroma/web/shout_channel_test.ex b/test/pleroma/web/shout_channel_test.ex
@@ -1,41 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Web.ShoutChannelTest do
- use Pleroma.Web.ChannelCase
- alias Pleroma.Web.ShoutChannel
- alias Pleroma.Web.UserSocket
-
- import Pleroma.Factory
-
- setup do
- user = insert(:user)
-
- {:ok, _, socket} =
- socket(UserSocket, "", %{user_name: user.nickname})
- |> subscribe_and_join(ShoutChannel, "shout:public")
-
- {:ok, socket: socket}
- end
-
- test "it broadcasts a message", %{socket: socket} do
- push(socket, "new_msg", %{"text" => "why is tenshi eating a corndog so cute?"})
- assert_broadcast("new_msg", %{text: "why is tenshi eating a corndog so cute?"})
- end
-
- describe "message lengths" do
- setup do: clear_config([:shout, :limit])
-
- test "it ignores messages of length zero", %{socket: socket} do
- push(socket, "new_msg", %{"text" => ""})
- refute_broadcast("new_msg", %{text: ""})
- end
-
- test "it ignores messages above a certain length", %{socket: socket} do
- clear_config([:shout, :limit], 2)
- push(socket, "new_msg", %{"text" => "123"})
- refute_broadcast("new_msg", %{text: "123"})
- end
- end
-end
diff --git a/test/pleroma/web/shout_channel_test.exs b/test/pleroma/web/shout_channel_test.exs
@@ -0,0 +1,41 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ShoutChannelTest do
+ use Pleroma.Web.ChannelCase
+ alias Pleroma.Web.ShoutChannel
+ alias Pleroma.Web.UserSocket
+
+ import Pleroma.Factory
+
+ setup do
+ user = insert(:user)
+
+ {:ok, _, socket} =
+ socket(UserSocket, "", %{user_name: user.nickname})
+ |> subscribe_and_join(ShoutChannel, "chat:public")
+
+ {:ok, socket: socket}
+ end
+
+ test "it broadcasts a message", %{socket: socket} do
+ push(socket, "new_msg", %{"text" => "why is tenshi eating a corndog so cute?"})
+ assert_broadcast("new_msg", %{text: "why is tenshi eating a corndog so cute?"})
+ end
+
+ describe "message lengths" do
+ setup do: clear_config([:shout, :limit])
+
+ test "it ignores messages of length zero", %{socket: socket} do
+ push(socket, "new_msg", %{"text" => ""})
+ refute_broadcast("new_msg", %{text: ""})
+ end
+
+ test "it ignores messages above a certain length", %{socket: socket} do
+ clear_config([:shout, :limit], 2)
+ push(socket, "new_msg", %{"text" => "123"})
+ refute_broadcast("new_msg", %{text: "123"})
+ end
+ end
+end