Merge remote-tracking branch 'pleroma/develop' into alias-router-helpers
[akkoma] / test / pleroma / config / release_runtime_provider_test.exs
1 defmodule Pleroma.Config.ReleaseRuntimeProviderTest do
2 use ExUnit.Case, async: true
3
4 alias Pleroma.Config.ReleaseRuntimeProvider
5
6 describe "load/2" do
7 test "loads release defaults config and warns about non-existent runtime config" do
8 ExUnit.CaptureIO.capture_io(fn ->
9 merged = ReleaseRuntimeProvider.load([], [])
10 assert merged == Pleroma.Config.Holder.release_defaults()
11 end) =~
12 "!!! Config path is not declared! Please ensure it exists and that PLEROMA_CONFIG_PATH is unset or points to an existing file"
13 end
14
15 test "merged runtime config" do
16 merged =
17 ReleaseRuntimeProvider.load([], config_path: "test/fixtures/config/temp.secret.exs")
18
19 assert merged[:pleroma][:first_setting] == [key: "value", key2: [Pleroma.Repo]]
20 assert merged[:pleroma][:second_setting] == [key: "value2", key2: ["Activity"]]
21 end
22
23 test "merged exported config" do
24 ExUnit.CaptureIO.capture_io(fn ->
25 merged =
26 ReleaseRuntimeProvider.load([],
27 exported_config_path: "test/fixtures/config/temp.exported_from_db.secret.exs"
28 )
29
30 assert merged[:pleroma][:exported_config_merged]
31 end) =~
32 "!!! Config path is not declared! Please ensure it exists and that PLEROMA_CONFIG_PATH is unset or points to an existing file"
33 end
34
35 test "runtime config is merged with exported config" do
36 merged =
37 ReleaseRuntimeProvider.load([],
38 config_path: "test/fixtures/config/temp.secret.exs",
39 exported_config_path: "test/fixtures/config/temp.exported_from_db.secret.exs"
40 )
41
42 assert merged[:pleroma][:first_setting] == [key2: [Pleroma.Repo], key: "new value"]
43 end
44 end
45 end