From 3f5c9f003b065ed95d0aa9ff05fc41ea7484f38e Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sat, 20 Jul 2024 14:17:35 -0400 Subject: [PATCH] Reorganize test group to have shared a shared setup --- test/pleroma/web/common_api_test.exs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs index a2c0432b8..75a30191a 100644 --- a/test/pleroma/web/common_api_test.exs +++ b/test/pleroma/web/common_api_test.exs @@ -1923,12 +1923,12 @@ defmodule Pleroma.Web.CommonAPITest do end describe "Oban jobs are cancelled" do - setup do: clear_config([:instance, :federating], true) + setup do + clear_config([:instance, :federating], true) - test "when deleting posts" do - user = insert(:user) + local_user = insert(:user) - follower_one = + remote_one = insert(:user, %{ local: false, nickname: "nick1@domain.com", @@ -1937,7 +1937,7 @@ defmodule Pleroma.Web.CommonAPITest do shared_inbox: "https://domain.com/inbox" }) - follower_two = + remote_two = insert(:user, %{ local: false, nickname: "nick2@example.com", @@ -1946,11 +1946,19 @@ defmodule Pleroma.Web.CommonAPITest do shared_inbox: "https://example.com/inbox" }) - {:ok, _, _} = Pleroma.User.follow(follower_one, user) - {:ok, _, _} = Pleroma.User.follow(follower_two, user) + %{local_user: local_user, remote_one: remote_one, remote_two: remote_two} + end + + test "when deleting posts", %{ + local_user: local_user, + remote_one: remote_one, + remote_two: remote_two + } do + {:ok, _, _} = Pleroma.User.follow(remote_one, local_user) + {:ok, _, _} = Pleroma.User.follow(remote_two, local_user) {:ok, %{data: %{"id" => ap_id}} = activity} = - CommonAPI.post(user, %{status: "Happy Friday everyone!"}) + CommonAPI.post(local_user, %{status: "Happy Friday everyone!"}) # Generate the publish_one jobs ObanHelpers.perform_all() @@ -1972,7 +1980,7 @@ defmodule Pleroma.Web.CommonAPITest do assert length(publish_one_jobs) == 2 # The delete should have triggered cancelling the publish_one jobs - assert {:ok, _delete} = CommonAPI.delete(activity.id, user) + assert {:ok, _delete} = CommonAPI.delete(activity.id, local_user) # all_enqueued/1 will not return cancelled jobs cancelled_jobs =