Test support: Add tag to stub pipeline mocks

This commit is contained in:
lain 2020-12-16 17:52:22 +01:00
parent 8e6a59384e
commit 74596982be
2 changed files with 31 additions and 10 deletions

View File

@ -125,11 +125,11 @@ defmodule Pleroma.Web.ConnCase do
end
if tags[:needs_streamer] do
start_supervised(%{
id: Pleroma.Web.Streamer.registry(),
start:
{Registry, :start_link, [[keys: :duplicate, name: Pleroma.Web.Streamer.registry()]]}
})
Pleroma.DataCase.start_streamer()
end
if tags[:stubbed_pipeline] do
Pleroma.DataCase.stub_pipeline()
end
{:ok, conn: Phoenix.ConnTest.build_conn()}

View File

@ -55,16 +55,37 @@ defmodule Pleroma.DataCase do
end
if tags[:needs_streamer] do
start_supervised(%{
id: Pleroma.Web.Streamer.registry(),
start:
{Registry, :start_link, [[keys: :duplicate, name: Pleroma.Web.Streamer.registry()]]}
})
start_streamer()
end
if tags[:stubbed_pipeline] do
stub_pipeline()
end
:ok
end
def start_streamer do
start_supervised(%{
id: Pleroma.Web.Streamer.registry(),
start: {Registry, :start_link, [[keys: :duplicate, name: Pleroma.Web.Streamer.registry()]]}
})
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])