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

@ -417,7 +417,7 @@ defmodule Pleroma.Emoji.Pack do
ttl_per_file = Pleroma.Config.get!([:emoji, :shared_pack_cache_seconds_per_file])
overall_ttl = :timer.seconds(ttl_per_file * Enum.count(files))
@cachex.put!(
@cachex.put(
:emoji_packs_cache,
pack.name,
# if pack.json MD5 changes, the cache is not valid anymore

View file

@ -40,7 +40,7 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheController do
defp fetch_entries(params) do
MediaProxy.cache_table()
|> @cachex.stream!(@cachex.Query.create(true, :key))
|> @cachex.stream!(Cachex.Query.create(true, :key))
|> filter_entries(params[:query])
end