From 41434ffcec47510de86cd9b06eb32521b897a1c9 Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 6 Jun 2024 19:14:38 +0400 Subject: Tests: Don't spawn processes in tests. --- lib/pleroma/web/mastodon_api/views/status_view.ex | 9 ++++++++- lib/pleroma/web/streamer.ex | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 0c16749a4..963658b1e 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do require Pleroma.Constants alias Pleroma.Activity + alias Pleroma.Config alias Pleroma.HTML alias Pleroma.Maps alias Pleroma.Object @@ -30,7 +31,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do # pagination is restricted to 40 activities at a time defp fetch_rich_media_for_activities(activities) do Enum.each(activities, fn activity -> - spawn(fn -> Card.get_by_activity(activity) end) + fun = fn -> Card.get_by_activity(activity) end + + if Config.get([__MODULE__, :sync_fetching], false) do + fun.() + else + spawn(fun) + end end) end diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 7065fdab2..9abdfae30 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -172,7 +172,13 @@ defmodule Pleroma.Web.Streamer do def stream(topics, items) do if should_env_send?() do for topic <- List.wrap(topics), item <- List.wrap(items) do - spawn(fn -> do_stream(topic, item) end) + fun = fn -> do_stream(topic, item) end + + if Config.get([__MODULE__, :sync_streaming], false) do + fun.() + else + spawn(fun) + end end end end -- cgit v1.2.3