From 1b57522bba4bbe2843b7c68d37e0530387e5b8f3 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 2 Apr 2018 13:13:04 +0200 Subject: [PATCH] Fix some test stuff. --- lib/pleroma/gopher/server.ex | 10 ++++++++-- .../twitter_api/twitter_api_controller_test.exs | 14 ++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/pleroma/gopher/server.ex b/lib/pleroma/gopher/server.ex index cfce4c05c..82e241f21 100644 --- a/lib/pleroma/gopher/server.ex +++ b/lib/pleroma/gopher/server.ex @@ -51,8 +51,9 @@ def init(ref, socket, transport, _Opts = []) do def info(text) do text = String.replace(text, ~r/[\t\n]/, "") + String.split(text, "\r") - |> Enum.map(fn (text) -> + |> Enum.map(fn text -> "i#{text}\tfake\(NULL)\t0\r\n" end) |> Enum.join("") @@ -82,7 +83,12 @@ def render_activities(activities) do link("Post ##{activity.id} by #{user.nickname}", "/notices/#{activity.id}") <> info("#{like_count} likes, #{announcement_count} repeats") <> - "\r\n" <> info(HtmlSanitizeEx.strip_tags(String.replace(activity.data["object"]["content"], "
", "\r"))) + "\r\n" <> + info( + HtmlSanitizeEx.strip_tags( + String.replace(activity.data["object"]["content"], "
", "\r") + ) + ) end) |> Enum.join("\r\n") end diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 5abdc2e0e..2cbcfd086 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -600,8 +600,9 @@ test "it returns a user's followers", %{conn: conn} do |> assign(:user, user) |> get("/api/statuses/followers") - assert json_response(conn, 200) == - UserView.render("index.json", %{users: [follower_one, follower_two], for: user}) + expected = UserView.render("index.json", %{users: [follower_one, follower_two], for: user}) + result = json_response(conn, 200) + assert Enum.sort(expected) == Enum.sort(result) end end @@ -620,12 +621,9 @@ test "it returns the logged in user's friends", %{conn: conn} do |> assign(:user, user) |> get("/api/statuses/friends") - assert MapSet.equal?( - MapSet.new(json_response(conn, 200)), - MapSet.new( - UserView.render("index.json", %{users: [followed_one, followed_two], for: user}) - ) - ) + expected = UserView.render("index.json", %{users: [followed_one, followed_two], for: user}) + result = json_response(conn, 200) + assert Enum.sort(expected) == Enum.sort(result) end test "it returns a given user's friends with user_id", %{conn: conn} do