logo

pleroma

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

refresh_counter_cache_test.exs (1144B)


  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.RefreshCounterCacheTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Web.CommonAPI
  7. import ExUnit.CaptureIO, only: [capture_io: 1]
  8. import Pleroma.Factory
  9. test "counts statuses" do
  10. user = insert(:user)
  11. other_user = insert(:user)
  12. CommonAPI.post(user, %{visibility: "public", status: "hey"})
  13. Enum.each(0..1, fn _ ->
  14. CommonAPI.post(user, %{
  15. visibility: "unlisted",
  16. status: "hey"
  17. })
  18. end)
  19. Enum.each(0..2, fn _ ->
  20. CommonAPI.post(user, %{
  21. visibility: "direct",
  22. status: "hey @#{other_user.nickname}"
  23. })
  24. end)
  25. Enum.each(0..3, fn _ ->
  26. CommonAPI.post(user, %{
  27. visibility: "private",
  28. status: "hey"
  29. })
  30. end)
  31. assert capture_io(fn -> Mix.Tasks.Pleroma.RefreshCounterCache.run([]) end) =~ "Done\n"
  32. assert %{"direct" => 3, "private" => 4, "public" => 1, "unlisted" => 2} =
  33. Pleroma.Stats.get_status_visibility_count()
  34. end
  35. end