mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-25 04:53:06 +00:00
Tests: Reset all cachex caches between synchronous tests
Don't bother in the async case, it doesn't make sense there.
This commit is contained in:
parent
6bb4f4e172
commit
c1129ff674
|
@ -116,12 +116,11 @@ defp json_response_and_validate_schema(conn, _status) do
|
||||||
end
|
end
|
||||||
|
|
||||||
setup tags do
|
setup tags do
|
||||||
Cachex.clear(:user_cache)
|
|
||||||
Cachex.clear(:object_cache)
|
|
||||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
|
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
|
||||||
|
|
||||||
unless tags[:async] do
|
unless tags[:async] do
|
||||||
Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, {:shared, self()})
|
Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, {:shared, self()})
|
||||||
|
Pleroma.DataCase.clear_cachex()
|
||||||
end
|
end
|
||||||
|
|
||||||
if tags[:needs_streamer] do
|
if tags[:needs_streamer] do
|
||||||
|
|
|
@ -45,13 +45,29 @@ defp oauth_access(scopes, opts \\ []) do
|
||||||
end
|
end
|
||||||
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
|
setup tags do
|
||||||
Cachex.clear(:user_cache)
|
|
||||||
Cachex.clear(:object_cache)
|
|
||||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
|
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
|
||||||
|
|
||||||
unless tags[:async] do
|
unless tags[:async] do
|
||||||
Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, {:shared, self()})
|
Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, {:shared, self()})
|
||||||
|
clear_cachex()
|
||||||
end
|
end
|
||||||
|
|
||||||
if tags[:needs_streamer] do
|
if tags[:needs_streamer] do
|
||||||
|
|
Loading…
Reference in a new issue