diff options
author | Roman Chvanikov <chvanikoff@pm.me> | 2019-07-09 21:21:09 +0300 |
---|---|---|
committer | Roman Chvanikov <chvanikoff@pm.me> | 2019-07-09 21:21:09 +0300 |
commit | 371d39e160efa51f2fe608e1788f6b11b89d9839 (patch) | |
tree | b5dc6280d713f11392fd47bffd1a675b527162f5 /test/user/synchronization_worker_test.exs | |
parent | d2cb18b2a342b990cc47dfdc42adb843c3db1b5e (diff) | |
parent | 670a77ecbc94d57c6ecb5e569597e81cee4b5532 (diff) | |
download | pleroma-371d39e160efa51f2fe608e1788f6b11b89d9839.tar.gz pleroma-371d39e160efa51f2fe608e1788f6b11b89d9839.zip |
Merge develop
Diffstat (limited to 'test/user/synchronization_worker_test.exs')
-rw-r--r-- | test/user/synchronization_worker_test.exs | 49 |
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 |