1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.CountStatusesTest do
9 alias Pleroma.Web.CommonAPI
11 import ExUnit.CaptureIO, only: [capture_io: 1]
12 import Pleroma.Factory
14 test "counts statuses" do
16 {:ok, _} = CommonAPI.post(user, %{"status" => "test"})
17 {:ok, _} = CommonAPI.post(user, %{"status" => "test2"})
20 {:ok, _} = CommonAPI.post(user2, %{"status" => "test3"})
22 user = refresh_record(user)
23 user2 = refresh_record(user2)
25 assert %{info: %{note_count: 2}} = user
26 assert %{info: %{note_count: 1}} = user2
28 {:ok, user} = User.update_info(user, &User.Info.set_note_count(&1, 0))
29 {:ok, user2} = User.update_info(user2, &User.Info.set_note_count(&1, 0))
31 assert %{info: %{note_count: 0}} = user
32 assert %{info: %{note_count: 0}} = user2
34 assert capture_io(fn -> Mix.Tasks.Pleroma.CountStatuses.run([]) end) == "Done\n"
36 assert %{info: %{note_count: 2}} = refresh_record(user)
37 assert %{info: %{note_count: 1}} = refresh_record(user2)