summaryrefslogtreecommitdiff
path: root/test/tasks/config_test.exs
diff options
context:
space:
mode:
authorAlexander <alex.strizhakov@gmail.com>2019-12-06 08:21:30 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2020-01-10 15:51:59 +0300
commit0656816c77875d87d64d89e0e549f73104104cfb (patch)
treef50d11260f92bde2352c18b6d1cb42c8bb46e90f /test/tasks/config_test.exs
parent2753285b7722fdb47f0ebb2180e997cf72f65d1a (diff)
downloadpleroma-0656816c77875d87d64d89e0e549f73104104cfb.tar.gz
pleroma-0656816c77875d87d64d89e0e549f73104104cfb.zip
tests for setttings without an explicit key
Diffstat (limited to 'test/tasks/config_test.exs')
-rw-r--r--test/tasks/config_test.exs8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/tasks/config_test.exs b/test/tasks/config_test.exs
index 055f678b9..dfe3904ca 100644
--- a/test/tasks/config_test.exs
+++ b/test/tasks/config_test.exs
@@ -24,19 +24,24 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
end
test "settings are migrated to db" do
+ initial = Application.get_all_env(:quack)
+ on_exit(fn -> Application.put_all_env([{:quack, initial}]) end)
assert Repo.all(Config) == []
Application.put_env(:pleroma, :first_setting, key: "value", key2: [Repo])
Application.put_env(:pleroma, :second_setting, key: "value2", key2: ["Activity"])
+ Application.put_env(:quack, :level, :info)
Mix.Tasks.Pleroma.Config.run(["migrate_to_db"])
config1 = Config.get_by_params(%{group: ":pleroma", key: ":first_setting"})
config2 = Config.get_by_params(%{group: ":pleroma", key: ":second_setting"})
+ config3 = Config.get_by_params(%{group: ":quack", key: ":level"})
refute Config.get_by_params(%{group: ":pleroma", key: "Pleroma.Repo"})
assert Config.from_binary(config1.value) == [key: "value", key2: [Repo]]
assert Config.from_binary(config2.value) == [key: "value2", key2: ["Activity"]]
+ assert Config.from_binary(config3.value) == :info
end
test "settings are migrated to file and deleted from db" do
@@ -59,6 +64,8 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
value: [key: "value2", key2: [Repo]]
})
+ Config.create(%{group: ":quack", key: ":level", value: :info})
+
Mix.Tasks.Pleroma.Config.run(["migrate_from_db", "--env", env, "-d"])
assert Repo.all(Config) == []
@@ -66,6 +73,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
file = File.read!(config_file)
assert file =~ "config :pleroma, :setting_first,"
assert file =~ "config :pleroma, :setting_second,"
+ assert file =~ "config :quack, :level, :info"
end
test "load a settings with large values and pass to file", %{temp_file: temp_file} do