X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fsupport%2Fhelpers.ex;h=34f1505d0e5adf41446a546ddfb45987fb13e3cd;hb=9542709f7224f4ced8d5c3f8fab4c74f541409cf;hp=15e8cbd9d51aeee9cdb289d3e9e012566daa55dd;hpb=6cd0586ef9f1991655c7736479a9a1fb39f4098c;p=akkoma
diff --git a/test/support/helpers.ex b/test/support/helpers.ex
index 15e8cbd9d..34f1505d0 100644
--- a/test/support/helpers.ex
+++ b/test/support/helpers.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Tests.Helpers do
@@ -8,6 +8,8 @@ defmodule Pleroma.Tests.Helpers do
"""
alias Pleroma.Config
+ require Logger
+
defmacro clear_config(config_path) do
quote do
clear_config(unquote(config_path)) do
@@ -18,6 +20,7 @@ defmodule Pleroma.Tests.Helpers do
defmacro clear_config(config_path, do: yield) do
quote do
initial_setting = Config.fetch(unquote(config_path))
+
unquote(yield)
on_exit(fn ->
@@ -35,6 +38,14 @@ defmodule Pleroma.Tests.Helpers do
end
defmacro clear_config(config_path, temp_setting) do
+ # NOTE: `clear_config([section, key], value)` != `clear_config([section], key: value)` (!)
+ # Displaying a warning to prevent unintentional clearing of all but one keys in section
+ if Keyword.keyword?(temp_setting) and length(temp_setting) == 1 do
+ Logger.warn(
+ "Please change `clear_config([section], key: value)` to `clear_config([section, key], value)`"
+ )
+ end
+
quote do
clear_config(unquote(config_path)) do
Config.put(unquote(config_path), unquote(temp_setting))