diff options
author | Mark Felder <feld@feld.me> | 2021-01-25 09:45:06 -0600 |
---|---|---|
committer | Mark Felder <feld@feld.me> | 2021-01-25 09:45:06 -0600 |
commit | 537ba1c5e07a33692ed63ca50b50e240efce6f88 (patch) | |
tree | 2a364998d729d1f65d5b87b5703604ac8d163678 /test/support/helpers.ex | |
parent | 28581e03ad5761aa484a7fa427be8ab5695f0892 (diff) | |
parent | 0a6f5f479348eff5f5404d4455fcb8254809812f (diff) | |
download | pleroma-537ba1c5e07a33692ed63ca50b50e240efce6f88.tar.gz pleroma-537ba1c5e07a33692ed63ca50b50e240efce6f88.zip |
Merge branch 'develop' into refactor/deactivated_user_field
Diffstat (limited to 'test/support/helpers.ex')
-rw-r--r-- | test/support/helpers.ex | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/support/helpers.ex b/test/support/helpers.ex index 4353d5254..856a6a376 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,15 @@ 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 to `clear_config([section]); 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)) |