X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=test%2Fpleroma%2Fconfig_test.exs;h=3158a2ec8d3d606f86510e60f549c03a338581c2;hb=f9ae7e72e9d745a1174353814d0ae6774f36ba3f;hp=1556e4237420cf35c253f7a19f43b7b57495dca6;hpb=64553ebae2f415b309df5f6b1c13b9972bc65aaa;p=akkoma
diff --git a/test/pleroma/config_test.exs b/test/pleroma/config_test.exs
index 1556e4237..3158a2ec8 100644
--- a/test/pleroma/config_test.exs
+++ b/test/pleroma/config_test.exs
@@ -1,9 +1,9 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ConfigTest do
- use ExUnit.Case
+ use Pleroma.DataCase
test "get/1 with an atom" do
assert Pleroma.Config.get(:instance) == Application.get_env(:pleroma, :instance)
@@ -30,9 +30,9 @@ defmodule Pleroma.ConfigTest do
describe "nil values" do
setup do
- Pleroma.Config.put(:lorem, nil)
- Pleroma.Config.put(:ipsum, %{dolor: [sit: nil]})
- Pleroma.Config.put(:dolor, sit: %{amet: nil})
+ clear_config(:lorem, nil)
+ clear_config(:ipsum, %{dolor: [sit: nil]})
+ clear_config(:dolor, sit: %{amet: nil})
on_exit(fn -> Enum.each(~w(lorem ipsum dolor)a, &Pleroma.Config.delete/1) end)
end
@@ -57,9 +57,9 @@ defmodule Pleroma.ConfigTest do
end
test "get/1 when value is false" do
- Pleroma.Config.put([:instance, :false_test], false)
- Pleroma.Config.put([:instance, :nested], [])
- Pleroma.Config.put([:instance, :nested, :false_test], false)
+ clear_config([:instance, :false_test], false)
+ clear_config([:instance, :nested], [])
+ clear_config([:instance, :nested, :false_test], false)
assert Pleroma.Config.get([:instance, :false_test]) == false
assert Pleroma.Config.get([:instance, :nested, :false_test]) == false
@@ -81,40 +81,40 @@ defmodule Pleroma.ConfigTest do
end
test "get!/1 when value is false" do
- Pleroma.Config.put([:instance, :false_test], false)
- Pleroma.Config.put([:instance, :nested], [])
- Pleroma.Config.put([:instance, :nested, :false_test], false)
+ clear_config([:instance, :false_test], false)
+ clear_config([:instance, :nested], [])
+ clear_config([:instance, :nested, :false_test], false)
assert Pleroma.Config.get!([:instance, :false_test]) == false
assert Pleroma.Config.get!([:instance, :nested, :false_test]) == false
end
test "put/2 with a key" do
- Pleroma.Config.put(:config_test, true)
+ clear_config(:config_test, true)
assert Pleroma.Config.get(:config_test) == true
end
test "put/2 with a list of keys" do
- Pleroma.Config.put([:instance, :config_test], true)
- Pleroma.Config.put([:instance, :config_nested_test], [])
- Pleroma.Config.put([:instance, :config_nested_test, :x], true)
+ clear_config([:instance, :config_test], true)
+ clear_config([:instance, :config_nested_test], [])
+ clear_config([:instance, :config_nested_test, :x], true)
assert Pleroma.Config.get([:instance, :config_test]) == true
assert Pleroma.Config.get([:instance, :config_nested_test, :x]) == true
end
test "delete/1 with a key" do
- Pleroma.Config.put([:delete_me], :delete_me)
+ clear_config([:delete_me], :delete_me)
Pleroma.Config.delete([:delete_me])
assert Pleroma.Config.get([:delete_me]) == nil
end
test "delete/2 with a list of keys" do
- Pleroma.Config.put([:delete_me], hello: "world", world: "Hello")
+ clear_config([:delete_me], hello: "world", world: "Hello")
Pleroma.Config.delete([:delete_me, :world])
assert Pleroma.Config.get([:delete_me]) == [hello: "world"]
- Pleroma.Config.put([:delete_me, :delete_me], hello: "world", world: "Hello")
+ clear_config([:delete_me, :delete_me], hello: "world", world: "Hello")
Pleroma.Config.delete([:delete_me, :delete_me, :world])
assert Pleroma.Config.get([:delete_me, :delete_me]) == [hello: "world"]
@@ -123,8 +123,8 @@ defmodule Pleroma.ConfigTest do
end
test "fetch/1" do
- Pleroma.Config.put([:lorem], :ipsum)
- Pleroma.Config.put([:ipsum], dolor: :sit)
+ clear_config([:lorem], :ipsum)
+ clear_config([:ipsum], dolor: :sit)
assert Pleroma.Config.fetch([:lorem]) == {:ok, :ipsum}
assert Pleroma.Config.fetch(:lorem) == {:ok, :ipsum}