aboutsummaryrefslogtreecommitdiff
path: root/test/user
diff options
context:
space:
mode:
Diffstat (limited to 'test/user')
-rw-r--r--test/user/synchronization_test.exs104
-rw-r--r--test/user/synchronization_worker_test.exs49
2 files changed, 0 insertions, 153 deletions
diff --git a/test/user/synchronization_test.exs b/test/user/synchronization_test.exs
deleted file mode 100644
index 67b669431..000000000
--- a/test/user/synchronization_test.exs
+++ /dev/null
@@ -1,104 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.User.SynchronizationTest do
- use Pleroma.DataCase
- import Pleroma.Factory
- alias Pleroma.User
- alias Pleroma.User.Synchronization
-
- setup do
- Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
- :ok
- end
-
- test "update following/followers 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")
-
- users = User.external_users()
- assert length(users) == 2
- {user, %{}} = Synchronization.call(users, %{})
- assert user == List.last(users)
-
- %{follower_count: followers, following_count: following} = User.get_cached_user_info(user1)
- assert followers == 437
- assert following == 152
-
- %{follower_count: followers, following_count: following} = User.get_cached_user_info(user2)
-
- assert followers == 527
- assert following == 267
- end
-
- test "don't check host if errors exist" do
- user1 = insert(:user, local: false, ap_id: "http://domain-with-errors:4001/users/fuser1")
-
- user2 = insert(:user, local: false, ap_id: "http://domain-with-errors:4001/users/fuser2")
-
- users = User.external_users()
- assert length(users) == 2
-
- {user, %{"domain-with-errors" => 2}} =
- Synchronization.call(users, %{"domain-with-errors" => 2}, max_retries: 2)
-
- assert user == List.last(users)
-
- %{follower_count: followers, following_count: following} = User.get_cached_user_info(user1)
- assert followers == 0
- assert following == 0
-
- %{follower_count: followers, following_count: following} = User.get_cached_user_info(user2)
-
- assert followers == 0
- assert following == 0
- end
-
- test "don't check host if errors appeared" do
- user1 = insert(:user, local: false, ap_id: "http://domain-with-errors:4001/users/fuser1")
-
- user2 = insert(:user, local: false, ap_id: "http://domain-with-errors:4001/users/fuser2")
-
- users = User.external_users()
- assert length(users) == 2
-
- {user, %{"domain-with-errors" => 2}} = Synchronization.call(users, %{}, max_retries: 2)
-
- assert user == List.last(users)
-
- %{follower_count: followers, following_count: following} = User.get_cached_user_info(user1)
- assert followers == 0
- assert following == 0
-
- %{follower_count: followers, following_count: following} = User.get_cached_user_info(user2)
-
- assert followers == 0
- assert following == 0
- end
-
- test "other users after error appeared" do
- user1 = insert(:user, local: false, ap_id: "http://domain-with-errors:4001/users/fuser1")
- user2 = insert(:user, local: false, ap_id: "http://localhost:4001/users/fuser2")
-
- users = User.external_users()
- assert length(users) == 2
-
- {user, %{"domain-with-errors" => 2}} = Synchronization.call(users, %{}, max_retries: 2)
- assert user == List.last(users)
-
- %{follower_count: followers, following_count: following} = User.get_cached_user_info(user1)
- assert followers == 0
- assert following == 0
-
- %{follower_count: followers, following_count: following} = User.get_cached_user_info(user2)
-
- assert followers == 527
- assert following == 267
- end
-end
diff --git a/test/user/synchronization_worker_test.exs b/test/user/synchronization_worker_test.exs
deleted file mode 100644
index 835c5327f..000000000
--- a/test/user/synchronization_worker_test.exs
+++ /dev/null
@@ -1,49 +0,0 @@
-# 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