1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.RefreshCounterCacheTest do
7 alias Pleroma.Web.CommonAPI
8 import ExUnit.CaptureIO, only: [capture_io: 1]
11 test "counts statuses" do
13 other_user = insert(:user)
15 CommonAPI.post(user, %{visibility: "public", status: "hey"})
17 Enum.each(0..1, fn _ ->
18 CommonAPI.post(user, %{
19 visibility: "unlisted",
24 Enum.each(0..2, fn _ ->
25 CommonAPI.post(user, %{
27 status: "hey @#{other_user.nickname}"
31 Enum.each(0..3, fn _ ->
32 CommonAPI.post(user, %{
33 visibility: "private",
38 assert capture_io(fn -> Mix.Tasks.Pleroma.RefreshCounterCache.run([]) end) =~ "Done\n"
40 assert %{direct: 3, private: 4, public: 1, unlisted: 2} =
41 Pleroma.Stats.get_status_visibility_count()