X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fsupport%2Fhelpers.ex;h=01eb4ad7fba1e46278bdbdb353b8781f541e2a5b;hb=dcac8adb3de7fb5545f6c6f18c9e1d5d82606594;hp=4353d5254b84f78f76254d34a0bae849eccdad48;hpb=c4439c630f46153c9f118d7f7e752d880206d262;p=akkoma diff --git a/test/support/helpers.ex b/test/support/helpers.ex index 4353d5254..01eb4ad7f 100644 --- a/test/support/helpers.ex +++ b/test/support/helpers.ex @@ -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) (#{inspect(config_path)} = #{inspect(temp_setting)})`" + ) + end + quote do clear_config(unquote(config_path)) do Config.put(unquote(config_path), unquote(temp_setting))