logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: c1402af2934219b6ab5dc40a7d87a8c916554647
parent 0c5cc519833166e1c748deb81394af9940c05928
Author: Lain Soykaf <lain@lain.com>
Date:   Sun, 12 Nov 2023 14:49:15 +0400

B Getting: Add default implementation, delegate, prepare test support.

Diffstat:

Mconfig/test.exs2++
Mlib/pleroma/config/getting.ex7+++++++
Mtest/support/mocks.ex1+
3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/config/test.exs b/config/test.exs @@ -141,6 +141,8 @@ config :pleroma, Pleroma.Search.Meilisearch, url: "http://127.0.0.1:7700/", priv # https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects config :phoenix, :plug_init_mode, :runtime +config :pleroma, :config_impl, Pleroma.UnstubbedConfigMock + if File.exists?("./config/test.secret.exs") do import_config "test.secret.exs" else diff --git a/lib/pleroma/config/getting.ex b/lib/pleroma/config/getting.ex @@ -5,4 +5,11 @@ defmodule Pleroma.Config.Getting do @callback get(any()) :: any() @callback get(any(), any()) :: any() + + def get(key), do: get(key, nil) + def get(key, default), do: impl().get(key, default) + + def impl() do + Application.get_env(:pleroma, :config_impl, Pleroma.Config) + end end diff --git a/test/support/mocks.ex b/test/support/mocks.ex @@ -26,5 +26,6 @@ Mox.defmock(Pleroma.Web.ActivityPub.SideEffectsMock, Mox.defmock(Pleroma.Web.FederatorMock, for: Pleroma.Web.Federator.Publishing) Mox.defmock(Pleroma.ConfigMock, for: Pleroma.Config.Getting) +Mox.defmock(Pleroma.UnstubbedConfigMock, for: Pleroma.Config.Getting) Mox.defmock(Pleroma.LoggerMock, for: Pleroma.Logging)