summaryrefslogtreecommitdiff
path: root/test/support/null_cache.ex
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-12-26 10:26:35 +0000
committerlain <lain@soykaf.club>2020-12-26 10:26:35 +0000
commite4f1d8f48c85b8a388d6c3945db157de5ce588c5 (patch)
tree3a3da119eb71a0536bd5f23226834dfea634d74a /test/support/null_cache.ex
parent88530c02d60900d1e0920d50c6c081a59010ea09 (diff)
parentfecefe68f88014ad2f8b5f290f3b0c7692fa3fef (diff)
downloadpleroma-e4f1d8f48c85b8a388d6c3945db157de5ce588c5.tar.gz
pleroma-e4f1d8f48c85b8a388d6c3945db157de5ce588c5.zip
Merge branch 'cachex-test' into 'develop'
Test framework overhaul (speed, reliability) See merge request pleroma/pleroma!3209
Diffstat (limited to 'test/support/null_cache.ex')
-rw-r--r--test/support/null_cache.ex49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/support/null_cache.ex b/test/support/null_cache.ex
new file mode 100644
index 000000000..c63df6a39
--- /dev/null
+++ b/test/support/null_cache.ex
@@ -0,0 +1,49 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.NullCache do
+ @moduledoc """
+ A module simulating a permanently empty cache.
+ """
+ @behaviour Pleroma.Caching
+
+ @impl true
+ def get!(_, _), do: nil
+
+ @impl true
+ def put(_, _, _, _ \\ nil), do: {:ok, true}
+
+ @impl true
+ def stream!(_, _), do: []
+
+ @impl true
+ def get(_, _), do: {:ok, nil}
+
+ @impl true
+ def fetch!(_, key, func) do
+ case func.(key) do
+ {_, res} -> res
+ res -> res
+ end
+ end
+
+ @impl true
+ def get_and_update(_, _, func) do
+ func.(nil)
+ end
+
+ @impl true
+ def expire_at(_, _, _), do: {:ok, true}
+
+ @impl true
+ def exists?(_, _), do: {:ok, false}
+
+ @impl true
+ def execute!(_, func) do
+ func.(:nothing)
+ end
+
+ @impl true
+ def del(_, _), do: {:ok, true}
+end