Merge branch 'fix/attachments-cleanup' into 'develop'
[akkoma] / test / web / mastodon_api / controllers / suggestion_controller_test.exs
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
5 defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
6 use Pleroma.Web.ConnCase
7
8 alias Pleroma.Config
9
10 import ExUnit.CaptureLog
11 import Pleroma.Factory
12 import Tesla.Mock
13
14 setup do: oauth_access(["read"])
15
16 setup %{user: user} do
17 other_user = insert(:user)
18 host = Config.get([Pleroma.Web.Endpoint, :url, :host])
19 url500 = "http://test500?#{host}&#{user.nickname}"
20 url200 = "http://test200?#{host}&#{user.nickname}"
21
22 mock(fn
23 %{method: :get, url: ^url500} ->
24 %Tesla.Env{status: 500, body: "bad request"}
25
26 %{method: :get, url: ^url200} ->
27 %Tesla.Env{
28 status: 200,
29 body:
30 ~s([{"acct":"yj455","avatar":"https://social.heldscal.la/avatar/201.jpeg","avatar_static":"https://social.heldscal.la/avatar/s/201.jpeg"}, {"acct":"#{
31 other_user.ap_id
32 }","avatar":"https://social.heldscal.la/avatar/202.jpeg","avatar_static":"https://social.heldscal.la/avatar/s/202.jpeg"}])
33 }
34 end)
35
36 [other_user: other_user]
37 end
38
39 test "returns empty result", %{conn: conn} do
40 res =
41 conn
42 |> get("/api/v1/suggestions")
43 |> json_response(200)
44
45 assert res == []
46 end
47 end