diff options
author | Mark Felder <feld@feld.me> | 2024-07-17 12:40:07 -0400 |
---|---|---|
committer | Mark Felder <feld@feld.me> | 2024-07-17 12:40:07 -0400 |
commit | d124d8645e1455fe5d4d2ab143f3ca09967f9572 (patch) | |
tree | 1e91d093e1549bfadf8c07a5353a5acbc1ae8eac /test | |
parent | b4c5cc39f65e3cd3e5e86be4631a3dcfb4bda593 (diff) | |
download | pleroma-d124d8645e1455fe5d4d2ab143f3ca09967f9572.tar.gz pleroma-d124d8645e1455fe5d4d2ab143f3ca09967f9572.zip |
Rework some Rich Media functionality for better error handling
Oban should not retry jobs that are likely to fail again
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/rich_media/parser_test.exs | 12 | ||||
-rw-r--r-- | test/support/http_request_mock.ex | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/test/pleroma/web/rich_media/parser_test.exs b/test/pleroma/web/rich_media/parser_test.exs index a5f2563a2..8fd75b57a 100644 --- a/test/pleroma/web/rich_media/parser_test.exs +++ b/test/pleroma/web/rich_media/parser_test.exs @@ -20,7 +20,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do end test "doesn't just add a title" do - assert {:error, {:invalid_metadata, _}} = Parser.parse("https://example.com/non-ogp") + assert {:error, :invalid_metadata} = Parser.parse("https://example.com/non-ogp") end test "parses ogp" do @@ -96,7 +96,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do end test "returns error if getting page was not successful" do - assert {:error, :overload} = Parser.parse("https://example.com/error") + assert {:error, :get} = Parser.parse("https://example.com/error") end test "does a HEAD request to check if the body is too large" do @@ -104,17 +104,17 @@ defmodule Pleroma.Web.RichMedia.ParserTest do end test "does a HEAD request to check if the body is html" do - assert {:error, {:content_type, _}} = Parser.parse("https://example.com/pdf-file") + assert {:error, :content_type} = Parser.parse("https://example.com/pdf-file") end test "refuses to crawl incomplete URLs" do url = "example.com/ogp" - assert :error == Parser.parse(url) + assert {:error, :validate} == Parser.parse(url) end test "refuses to crawl malformed URLs" do url = "example.com[]/ogp" - assert :error == Parser.parse(url) + assert {:error, :validate} == Parser.parse(url) end test "refuses to crawl URLs of private network from posts" do @@ -126,7 +126,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do "https://pleroma.local/notice/9kCP7V" ] |> Enum.each(fn url -> - assert :error == Parser.parse(url) + assert {:error, :validate} == Parser.parse(url) end) end diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex index 20e410424..ed044cf98 100644 --- a/test/support/http_request_mock.ex +++ b/test/support/http_request_mock.ex @@ -1724,7 +1724,7 @@ defmodule HttpRequestMock do ] def head(url, _query, _body, _headers) when url in @rich_media_mocks do - {:ok, %Tesla.Env{status: 404, body: ""}} + {:ok, %Tesla.Env{status: 200, body: ""}} end def head("https://example.com/pdf-file", _, _, _) do |