Default DB configuration to false and set the default database name to
[akkoma] / test / config / transfer_task_test.exs
1 defmodule Pleroma.Config.TransferTaskTest do
2 use Pleroma.DataCase
3
4 setup do
5 dynamic = Pleroma.Config.get([:instance, :dynamic_configuration])
6
7 Pleroma.Config.put([:instance, :dynamic_configuration], true)
8
9 on_exit(fn ->
10 Pleroma.Config.put([:instance, :dynamic_configuration], dynamic)
11 end)
12 end
13
14 test "transfer config values from db to env" do
15 refute Application.get_env(:pleroma, :test_key)
16 Pleroma.Web.AdminAPI.Config.create(%{key: "test_key", value: [live: 2, com: 3]})
17
18 Pleroma.Config.TransferTask.start_link()
19
20 assert Application.get_env(:pleroma, :test_key) == [live: 2, com: 3]
21
22 on_exit(fn ->
23 Application.delete_env(:pleroma, :test_key)
24 end)
25 end
26
27 test "non existing atom" do
28 Pleroma.Web.AdminAPI.Config.create(%{key: "undefined_atom_key", value: [live: 2, com: 3]})
29
30 assert ExUnit.CaptureLog.capture_log(fn ->
31 Pleroma.Config.TransferTask.start_link()
32 end) =~
33 "updating env causes error, key: \"undefined_atom_key\", error: %ArgumentError{message: \"argument error\"}"
34 end
35 end