X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fconfig%2Ftransfer_task_test.exs;h=473899d1d57e1ecf5a74548562a6659a638b0385;hb=ae921a0c24b9b1dcdea408decc691d66a538b6b8;hp=ebdc951cf71576e4052bc1da498ac1b79db435f7;hpb=6813c0302c2b665d337d5f5831d2df6312b6b277;p=akkoma
diff --git a/test/config/transfer_task_test.exs b/test/config/transfer_task_test.exs
index ebdc951cf..473899d1d 100644
--- a/test/config/transfer_task_test.exs
+++ b/test/config/transfer_task_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Config.TransferTaskTest do
@@ -10,14 +10,14 @@ defmodule Pleroma.Config.TransferTaskTest do
alias Pleroma.Config.TransferTask
alias Pleroma.ConfigDB
- clear_config(:configurable_from_database) do
- Pleroma.Config.put(:configurable_from_database, true)
- end
+ setup do: clear_config(:configurable_from_database, true)
test "transfer config values from db to env" do
refute Application.get_env(:pleroma, :test_key)
refute Application.get_env(:idna, :test_key)
refute Application.get_env(:quack, :test_key)
+ refute Application.get_env(:postgrex, :test_key)
+ initial = Application.get_env(:logger, :level)
ConfigDB.create(%{
group: ":pleroma",
@@ -37,16 +37,28 @@ defmodule Pleroma.Config.TransferTaskTest do
value: [:test_value1, :test_value2]
})
+ ConfigDB.create(%{
+ group: ":postgrex",
+ key: ":test_key",
+ value: :value
+ })
+
+ ConfigDB.create(%{group: ":logger", key: ":level", value: :debug})
+
TransferTask.start_link([])
assert Application.get_env(:pleroma, :test_key) == [live: 2, com: 3]
assert Application.get_env(:idna, :test_key) == [live: 15, com: 35]
assert Application.get_env(:quack, :test_key) == [:test_value1, :test_value2]
+ assert Application.get_env(:logger, :level) == :debug
+ assert Application.get_env(:postgrex, :test_key) == :value
on_exit(fn ->
Application.delete_env(:pleroma, :test_key)
Application.delete_env(:idna, :test_key)
Application.delete_env(:quack, :test_key)
+ Application.delete_env(:postgrex, :test_key)
+ Application.put_env(:logger, :level, initial)
end)
end
@@ -70,7 +82,7 @@ defmodule Pleroma.Config.TransferTaskTest do
assert Application.get_env(:quack, :level) == :info
assert Application.get_env(:quack, :meta) == [:none]
- default = Pleroma.Config.Holder.config(:quack, :webhook_url)
+ default = Pleroma.Config.Holder.default_config(:quack, :webhook_url)
assert Application.get_env(:quack, :webhook_url) == default
on_exit(fn ->
@@ -80,8 +92,8 @@ defmodule Pleroma.Config.TransferTaskTest do
end
test "transfer config values with full subkey update" do
- emoji = Application.get_env(:pleroma, :emoji)
- assets = Application.get_env(:pleroma, :assets)
+ clear_config(:emoji)
+ clear_config(:assets)
ConfigDB.create(%{
group: ":pleroma",
@@ -101,17 +113,15 @@ defmodule Pleroma.Config.TransferTaskTest do
assert emoji_env[:groups] == [a: 1, b: 2]
assets_env = Application.get_env(:pleroma, :assets)
assert assets_env[:mascots] == [a: 1, b: 2]
-
- on_exit(fn ->
- Application.put_env(:pleroma, :emoji, emoji)
- Application.put_env(:pleroma, :assets, assets)
- end)
end
describe "pleroma restart" do
+ setup do
+ on_exit(fn -> Restarter.Pleroma.refresh() end)
+ end
+
test "don't restart if no reboot time settings were changed" do
- emoji = Application.get_env(:pleroma, :emoji)
- on_exit(fn -> Application.put_env(:pleroma, :emoji, emoji) end)
+ clear_config(:emoji)
ConfigDB.create(%{
group: ":pleroma",
@@ -125,9 +135,8 @@ defmodule Pleroma.Config.TransferTaskTest do
)
end
- test "restart pleroma on reboot time key" do
- chat = Application.get_env(:pleroma, :chat)
- on_exit(fn -> Application.put_env(:pleroma, :chat, chat) end)
+ test "on reboot time key" do
+ clear_config(:chat)
ConfigDB.create(%{
group: ":pleroma",
@@ -138,9 +147,8 @@ defmodule Pleroma.Config.TransferTaskTest do
assert capture_log(fn -> TransferTask.start_link([]) end) =~ "pleroma restarted"
end
- test "restart pleroma on reboot time subkey" do
- captcha = Application.get_env(:pleroma, Pleroma.Captcha)
- on_exit(fn -> Application.put_env(:pleroma, Pleroma.Captcha, captcha) end)
+ test "on reboot time subkey" do
+ clear_config(Pleroma.Captcha)
ConfigDB.create(%{
group: ":pleroma",
@@ -152,13 +160,8 @@ defmodule Pleroma.Config.TransferTaskTest do
end
test "don't restart pleroma on reboot time key and subkey if there is false flag" do
- chat = Application.get_env(:pleroma, :chat)
- captcha = Application.get_env(:pleroma, Pleroma.Captcha)
-
- on_exit(fn ->
- Application.put_env(:pleroma, :chat, chat)
- Application.put_env(:pleroma, Pleroma.Captcha, captcha)
- end)
+ clear_config(:chat)
+ clear_config(Pleroma.Captcha)
ConfigDB.create(%{
group: ":pleroma",