logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

count_statuses_test.exs (1121B)


  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. defmodule Mix.Tasks.Pleroma.CountStatusesTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.User
  7. alias Pleroma.Web.CommonAPI
  8. import ExUnit.CaptureIO, only: [capture_io: 1]
  9. import Pleroma.Factory
  10. test "counts statuses" do
  11. user = insert(:user)
  12. {:ok, _} = CommonAPI.post(user, %{status: "test"})
  13. {:ok, _} = CommonAPI.post(user, %{status: "test2"})
  14. user2 = insert(:user)
  15. {:ok, _} = CommonAPI.post(user2, %{status: "test3"})
  16. user = refresh_record(user)
  17. user2 = refresh_record(user2)
  18. assert %{note_count: 2} = user
  19. assert %{note_count: 1} = user2
  20. {:ok, user} = User.update_note_count(user, 0)
  21. {:ok, user2} = User.update_note_count(user2, 0)
  22. assert %{note_count: 0} = user
  23. assert %{note_count: 0} = user2
  24. assert capture_io(fn -> Mix.Tasks.Pleroma.CountStatuses.run([]) end) == "Done\n"
  25. assert %{note_count: 2} = refresh_record(user)
  26. assert %{note_count: 1} = refresh_record(user2)
  27. end
  28. end