aboutsummaryrefslogtreecommitdiff
path: root/test/support/helpers.ex
diff options
context:
space:
mode:
authorMaksim Pechnikov <parallel588@gmail.com>2019-12-08 20:14:28 +0300
committerMaksim Pechnikov <parallel588@gmail.com>2019-12-08 20:14:28 +0300
commit6fbafb1cdcba3dc2a7e8b9718e295c9811a726d9 (patch)
tree6b8e22663fd5b6d5cdf3afaa4b306775d59b503a /test/support/helpers.ex
parent49bb0a130f93476d32d3177d7a989b7a98a063f2 (diff)
parentaf5fef1f228a1781d7d9cad490d3b3a783389f5e (diff)
downloadpleroma-6fbafb1cdcba3dc2a7e8b9718e295c9811a726d9.tar.gz
Merge branch 'develop' into issue/1276
Diffstat (limited to 'test/support/helpers.ex')
-rw-r--r--test/support/helpers.ex17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/support/helpers.ex b/test/support/helpers.ex
index ce39dd9d8..af2b2eddf 100644
--- a/test/support/helpers.ex
+++ b/test/support/helpers.ex
@@ -75,6 +75,23 @@ defmodule Pleroma.Tests.Helpers do
|> Poison.decode!()
end
+ def stringify_keys(nil), do: nil
+
+ def stringify_keys(key) when key in [true, false], do: key
+ def stringify_keys(key) when is_atom(key), do: Atom.to_string(key)
+
+ def stringify_keys(map) when is_map(map) do
+ map
+ |> Enum.map(fn {k, v} -> {stringify_keys(k), stringify_keys(v)} end)
+ |> Enum.into(%{})
+ end
+
+ def stringify_keys([head | rest] = list) when is_list(list) do
+ [stringify_keys(head) | stringify_keys(rest)]
+ end
+
+ def stringify_keys(key), do: key
+
defmacro guards_config(config_path) do
quote do
initial_setting = Pleroma.Config.get(config_path)