Tests: Use NullCache for async tests.

Caching can't work in async tests, so for them it is mocked to a
null cache that is always empty. Synchronous tests are stubbed
with the real Cachex, which is emptied after every test.
This commit is contained in:
lain 2020-12-18 19:49:01 +01:00
commit 95a9bdfc37
13 changed files with 119 additions and 11 deletions

View file

@ -65,8 +65,13 @@ defmodule Pleroma.DataCase do
setup tags do
: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