diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-12-26 22:23:05 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-12-26 22:23:05 +0300 |
commit | 4134abef63e1165f5701741c1012e64cb908654c (patch) | |
tree | bf531d2f464297c46edeaaf02e6966c1695934a5 /test/support/data_case.ex | |
parent | cbb19d0e1882f5ce641f30b51d7156336f81aba9 (diff) | |
parent | e4f1d8f48c85b8a388d6c3945db157de5ce588c5 (diff) | |
download | pleroma-4134abef63e1165f5701741c1012e64cb908654c.tar.gz |
Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags-rework
Diffstat (limited to 'test/support/data_case.ex')
-rw-r--r-- | test/support/data_case.ex | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/test/support/data_case.ex b/test/support/data_case.ex index d5456521c..5c657c1d9 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -45,13 +45,34 @@ defmodule Pleroma.DataCase do end end + def clear_cachex do + Pleroma.Supervisor + |> Supervisor.which_children() + |> Enum.each(fn + {name, _, _, [Cachex]} -> + name + |> to_string + |> String.trim_leading("cachex_") + |> Kernel.<>("_cache") + |> String.to_existing_atom() + |> Cachex.clear() + + _ -> + nil + end) + end + setup tags do - Cachex.clear(:user_cache) - Cachex.clear(:object_cache) :ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo) - unless tags[:async] do + if tags[:async] do + Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache) + Mox.set_mox_private() + else Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, {:shared, self()}) + Mox.stub_with(Pleroma.CachexMock, Pleroma.CachexProxy) + Mox.set_mox_global() + clear_cachex() end if tags[:needs_streamer] do @@ -62,9 +83,25 @@ defmodule Pleroma.DataCase do }) end + stub_pipeline() + :ok end + def stub_pipeline do + Mox.stub_with(Pleroma.Web.ActivityPub.SideEffectsMock, Pleroma.Web.ActivityPub.SideEffects) + + Mox.stub_with( + Pleroma.Web.ActivityPub.ObjectValidatorMock, + Pleroma.Web.ActivityPub.ObjectValidator + ) + + Mox.stub_with(Pleroma.Web.ActivityPub.MRFMock, Pleroma.Web.ActivityPub.MRF) + Mox.stub_with(Pleroma.Web.ActivityPub.ActivityPubMock, Pleroma.Web.ActivityPub.ActivityPub) + Mox.stub_with(Pleroma.Web.FederatorMock, Pleroma.Web.Federator) + Mox.stub_with(Pleroma.ConfigMock, Pleroma.Config) + end + def ensure_local_uploader(context) do test_uploader = Map.get(context, :uploader, Pleroma.Uploaders.Local) uploader = Pleroma.Config.get([Pleroma.Upload, :uploader]) |