tests: add tests for MRF.describe()
authorAriadne Conill <ariadne@dereferenced.org>
Tue, 13 Aug 2019 22:19:15 +0000 (22:19 +0000)
committerAriadne Conill <ariadne@dereferenced.org>
Tue, 13 Aug 2019 22:19:15 +0000 (22:19 +0000)
test/support/mrf_module_mock.ex
test/web/activity_pub/mrf/mrf_test.exs

index e5ae21ad84e3bdb92b377308be283e237495f99c..573eb0147d7f28ec8bc6242b070d7da07fdd9ebf 100644 (file)
@@ -9,5 +9,5 @@ defmodule MRFModuleMock do
   def filter(message), do: {:ok, message}
 
   @impl true
-  def describe(), do: %{"mrf_module_mock" => "some config data"}
+  def describe(), do: {:ok, %{mrf_module_mock: "some config data"}}
 end
index 1a888e18f8bc9fc9d9999012a710d4be89a15d1f..19e1729394e72e9fa2a2a49ed30d9c9a2f04d571 100644 (file)
@@ -57,4 +57,30 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
       refute MRF.subdomain_match?(regexes, "example.com")
     end
   end
+
+  describe "describe/0" do
+    test "it works as expected with noop policy" do
+      expected = %{
+        mrf_policies: ["NoOpPolicy"],
+        exclusions: false
+      }
+
+      {:ok, ^expected} = MRF.describe()
+    end
+
+    test "it works as expected with mock policy" do
+      config = Pleroma.Config.get([:instance, :rewrite_policy])
+      Pleroma.Config.put([:instance, :rewrite_policy], [MRFModuleMock])
+
+      expected = %{
+        mrf_policies: ["MRFModuleMock"],
+        mrf_module_mock: "some config data",
+        exclusions: false
+      }
+
+      {:ok, ^expected} = MRF.describe()
+
+      Pleroma.Config.put([:instance, :rewrite_policy], config)
+    end
+  end
 end