X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fobject%2Ffetcher_test.exs;h=3b666e0d141fc77a8604442c1087b7622041a598;hb=a87c313309b73ced5970c59d00117c357f51fecb;hp=d604fd5f59f42e1528e8df22d10cd63b5fd68c39;hpb=0c53d91f3bfe7bbd8d8b9ffd332ac2f57b6aba34;p=akkoma diff --git a/test/object/fetcher_test.exs b/test/object/fetcher_test.exs index d604fd5f5..3b666e0d1 100644 --- a/test/object/fetcher_test.exs +++ b/test/object/fetcher_test.exs @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Object.FetcherTest do use Pleroma.DataCase @@ -7,7 +11,17 @@ defmodule Pleroma.Object.FetcherTest do import Tesla.Mock setup do - mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + mock(fn + %{method: :get, url: "https://mastodon.example.org/users/userisgone"} -> + %Tesla.Env{status: 410} + + %{method: :get, url: "https://mastodon.example.org/users/userisgone404"} -> + %Tesla.Env{status: 404} + + env -> + apply(HttpRequestMock, :request, [env]) + end) + :ok end @@ -81,10 +95,24 @@ defmodule Pleroma.Object.FetcherTest do end test "all objects with fake directions are rejected by the object fetcher" do - {:error, _} = - Fetcher.fetch_and_contain_remote_object_from_id( - "https://info.pleroma.site/activity4.json" - ) + assert {:error, _} = + Fetcher.fetch_and_contain_remote_object_from_id( + "https://info.pleroma.site/activity4.json" + ) + end + + test "handle HTTP 410 Gone response" do + assert {:error, "Object has been deleted"} == + Fetcher.fetch_and_contain_remote_object_from_id( + "https://mastodon.example.org/users/userisgone" + ) + end + + test "handle HTTP 404 response" do + assert {:error, "Object has been deleted"} == + Fetcher.fetch_and_contain_remote_object_from_id( + "https://mastodon.example.org/users/userisgone404" + ) end end