Merge branch 'patch-1' into 'develop'
[akkoma] / test / config / loader_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Config.LoaderTest do
6 use ExUnit.Case, async: true
7
8 alias Pleroma.Config.Loader
9
10 test "load/1" do
11 config = Loader.load("test/fixtures/config/temp.secret.exs")
12 assert config[:pleroma][:first_setting][:key] == "value"
13 assert config[:pleroma][:first_setting][:key2] == [Pleroma.Repo]
14 assert config[:quack][:level] == :info
15 end
16
17 test "load_and_merge/0" do
18 config = Loader.load_and_merge()
19
20 refute config[:pleroma][Pleroma.Repo]
21 refute config[:pleroma][Pleroma.Web.Endpoint]
22 refute config[:pleroma][:env]
23 refute config[:pleroma][:configurable_from_database]
24 refute config[:pleroma][:database]
25 refute config[:phoenix][:serve_endpoints]
26
27 assert config[:pleroma][:ecto_repos] == [Pleroma.Repo]
28 assert config[:pleroma][Pleroma.Uploaders.Local][:uploads] == "test/uploads"
29 assert config[:tesla][:adapter] == Tesla.Mock
30 end
31
32 test "filter_group/2" do
33 assert Loader.filter_group(:pleroma,
34 pleroma: [
35 {Pleroma.Repo, [a: 1, b: 2]},
36 {Pleroma.Upload, [a: 1, b: 2]},
37 {Pleroma.Web.Endpoint, []},
38 env: :test,
39 configurable_from_database: true,
40 database: []
41 ]
42 ) == [{Pleroma.Upload, [a: 1, b: 2]}]
43 end
44 end