diff options
author | lain <lain@soykaf.club> | 2020-08-05 15:59:30 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-08-05 15:59:30 +0000 |
commit | 9688e332d0985ccb1ea62206a62b21ecf65b0715 (patch) | |
tree | c893c4a2622a1d33e91b91825e35109c83fb44ba /test/support | |
parent | 474aba984f2184d4f028c56f687d1a12f69d5c47 (diff) | |
parent | 8c57a299b463b7e5916addbbd3571b35e1742ebd (diff) | |
download | pleroma-9688e332d0985ccb1ea62206a62b21ecf65b0715.tar.gz |
Merge branch 'refactor/config-get' into 'develop'
Refactor Pleroma.Config.get to return consistent results for nil values
Closes #2001
See merge request pleroma/pleroma!2853
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/helpers.ex | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/support/helpers.ex b/test/support/helpers.ex index 5cbf2e291..ecd4b1e18 100644 --- a/test/support/helpers.ex +++ b/test/support/helpers.ex @@ -17,9 +17,19 @@ defmodule Pleroma.Tests.Helpers do defmacro clear_config(config_path, do: yield) do quote do - initial_setting = Config.get(unquote(config_path)) + initial_setting = Config.fetch(unquote(config_path)) unquote(yield) - on_exit(fn -> Config.put(unquote(config_path), initial_setting) end) + + on_exit(fn -> + case initial_setting do + :error -> + Config.delete(unquote(config_path)) + + {:ok, value} -> + Config.put(unquote(config_path), value) + end + end) + :ok end end |