summaryrefslogtreecommitdiff
path: root/test/user/synchronization_worker_test.exs
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2019-07-11 13:26:59 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2019-07-11 13:26:59 +0700
commit182f7bbb1170c44eac4ab4a9efa4ff0bff991c98 (patch)
treef4c6fe46e82f667be49c8e6aad0ed3b418e4332f /test/user/synchronization_worker_test.exs
parentddd4a09b72ede65345ddf45a68eb239b54eda86c (diff)
parent4016341a77337e3b71295d27808eebc05152b086 (diff)
downloadpleroma-182f7bbb1170c44eac4ab4a9efa4ff0bff991c98.tar.gz
pleroma-182f7bbb1170c44eac4ab4a9efa4ff0bff991c98.zip
Merge branch 'develop' into feature/addressable-lists
Diffstat (limited to 'test/user/synchronization_worker_test.exs')
-rw-r--r--test/user/synchronization_worker_test.exs49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/user/synchronization_worker_test.exs b/test/user/synchronization_worker_test.exs
new file mode 100644
index 000000000..835c5327f
--- /dev/null
+++ b/test/user/synchronization_worker_test.exs
@@ -0,0 +1,49 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.User.SynchronizationWorkerTest do
+ use Pleroma.DataCase
+ import Pleroma.Factory
+
+ setup do
+ Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
+
+ config = Pleroma.Config.get([:instance, :external_user_synchronization])
+
+ for_update = [enabled: true, interval: 1000]
+
+ Pleroma.Config.put([:instance, :external_user_synchronization], for_update)
+
+ on_exit(fn ->
+ Pleroma.Config.put([:instance, :external_user_synchronization], config)
+ end)
+
+ :ok
+ end
+
+ test "sync follow counters" do
+ user1 =
+ insert(:user,
+ local: false,
+ ap_id: "http://localhost:4001/users/masto_closed"
+ )
+
+ user2 = insert(:user, local: false, ap_id: "http://localhost:4001/users/fuser2")
+
+ {:ok, _} = Pleroma.User.SynchronizationWorker.start_link()
+ :timer.sleep(1500)
+
+ %{follower_count: followers, following_count: following} =
+ Pleroma.User.get_cached_user_info(user1)
+
+ assert followers == 437
+ assert following == 152
+
+ %{follower_count: followers, following_count: following} =
+ Pleroma.User.get_cached_user_info(user2)
+
+ assert followers == 527
+ assert following == 267
+ end
+end