Apply suggestion to config/description.exs
[akkoma] / test / tasks / refresh_counter_cache_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Mix.Tasks.Pleroma.RefreshCounterCacheTest do
6 use Pleroma.DataCase
7 alias Pleroma.Web.CommonAPI
8 import ExUnit.CaptureIO, only: [capture_io: 1]
9 import Pleroma.Factory
10
11 test "counts statuses" do
12 user = insert(:user)
13 other_user = insert(:user)
14
15 CommonAPI.post(user, %{visibility: "public", status: "hey"})
16
17 Enum.each(0..1, fn _ ->
18 CommonAPI.post(user, %{
19 visibility: "unlisted",
20 status: "hey"
21 })
22 end)
23
24 Enum.each(0..2, fn _ ->
25 CommonAPI.post(user, %{
26 visibility: "direct",
27 status: "hey @#{other_user.nickname}"
28 })
29 end)
30
31 Enum.each(0..3, fn _ ->
32 CommonAPI.post(user, %{
33 visibility: "private",
34 status: "hey"
35 })
36 end)
37
38 assert capture_io(fn -> Mix.Tasks.Pleroma.RefreshCounterCache.run([]) end) =~ "Done\n"
39
40 assert %{direct: 3, private: 4, public: 1, unlisted: 2} =
41 Pleroma.Stats.get_status_visibility_count()
42 end
43 end