Test URL formatting
authorMark Felder <feld@feld.me>
Thu, 21 Jan 2021 20:42:16 +0000 (14:42 -0600)
committerMark Felder <feld@feld.me>
Thu, 21 Jan 2021 20:42:16 +0000 (14:42 -0600)
test/pleroma/web/media_proxy/invalidation/script_test.exs

index 854de8a3b54b7912da60192d03e697ae9b196e04..e9629b72bea77ac333e934792a4c96965c1262ad 100644 (file)
@@ -23,4 +23,30 @@ defmodule Pleroma.Web.MediaProxy.Invalidation.ScriptTest do
              ) == {:error, "\"not found script path\""}
     end)
   end
+
+  describe "url formatting" do
+    setup do
+      urls = [
+        "https://bikeshed.party/media/foo.png",
+        "http://safe.millennial.space/proxy/wheeeee.gif",
+        "https://lain.com/proxy/mediafile.mp4?foo&bar=true",
+        "http://localhost:4000/media/upload.jpeg"
+      ]
+
+      [urls: urls]
+    end
+
+    test "with invalid formatter", %{urls: urls} do
+      assert urls == Invalidation.Script.maybe_format_urls(urls, nil)
+    end
+
+    test "with :htcacheclean formatter", %{urls: urls} do
+      assert [
+               "https://bikeshed.party:443/media/foo.png?",
+               "http://safe.millennial.space:80/proxy/wheeeee.gif?",
+               "https://lain.com:443/proxy/mediafile.mp4?foo&bar=true",
+               "http://localhost:4000/media/upload.jpeg?"
+             ] == Invalidation.Script.maybe_format_urls(urls, :htcacheclean)
+    end
+  end
 end