summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-12-04 16:58:16 -0500
committerAlex Gleason <alex@alexgleason.me>2021-12-04 16:58:16 -0500
commit80f8d9186b9e2c5f06fc56dfbc757e75a57b17b9 (patch)
treebc97bcfcfe2f3d044a87a12940ee43d6e8da7bb7
parent0b2119d4a791b3623b304b0bab683609d23271d4 (diff)
Create a test for Home timeline query missing indexfix-home-timeline
-rw-r--r--test/pleroma/web/activity_pub/activity_pub_query_test.exs44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/pleroma/web/activity_pub/activity_pub_query_test.exs b/test/pleroma/web/activity_pub/activity_pub_query_test.exs
new file mode 100644
index 000000000..ef0691acd
--- /dev/null
+++ b/test/pleroma/web/activity_pub/activity_pub_query_test.exs
@@ -0,0 +1,44 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ActivityPub.ActivityPubQueryTest do
+ use Pleroma.DataCase
+ use Oban.Testing, repo: Pleroma.Repo
+
+ alias Pleroma.Repo
+ alias Pleroma.User
+ alias Pleroma.Web.ActivityPub.ActivityPub
+
+ import Pleroma.Factory
+
+ test "fetch_activities_query/2 indexes" do
+ # Add a few accounts for good measure
+ insert_list(3, :user)
+
+ user = insert(:user)
+ follower = insert(:user)
+
+ # Create a follower
+ User.follow(follower, user)
+
+ # Same opts used by the Home timeline
+ opts = %{
+ type: ["Create", "Announce"],
+ blocking_user: user,
+ muting_user: user,
+ reply_filtering_user: user,
+ announce_filtering_user: user,
+ user: user
+ }
+
+ # I don't fully understand this but it's what the Home timeline does
+ recipients = [user.ap_id | User.following(user)]
+
+ # Build the query
+ query = ActivityPub.fetch_activities_query(recipients, opts)
+
+ # Performs an EXPLAIN, fail if it's a sequence scan
+ refute Repo.explain(:all, query) =~ "Seq Scan"
+ end
+end