forked from AkkomaGang/akkoma
Capture log in object refetch tests
This commit is contained in:
parent
eae9a6d34d
commit
f95ae0e50a
1 changed files with 16 additions and 9 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
defmodule Pleroma.ObjectTest do
|
defmodule Pleroma.ObjectTest do
|
||||||
use Pleroma.DataCase
|
use Pleroma.DataCase
|
||||||
|
import ExUnit.CaptureLog
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
import Tesla.Mock
|
import Tesla.Mock
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
|
@ -134,8 +135,12 @@ test "returns the old object if refetch fails" do
|
||||||
assert Enum.at(object.data["oneOf"], 0)["replies"]["totalItems"] == 4
|
assert Enum.at(object.data["oneOf"], 0)["replies"]["totalItems"] == 4
|
||||||
assert Enum.at(object.data["oneOf"], 1)["replies"]["totalItems"] == 0
|
assert Enum.at(object.data["oneOf"], 1)["replies"]["totalItems"] == 0
|
||||||
|
|
||||||
|
assert capture_log(fn ->
|
||||||
mock(fn
|
mock(fn
|
||||||
%{method: :get, url: "https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d"} ->
|
%{
|
||||||
|
method: :get,
|
||||||
|
url: "https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d"
|
||||||
|
} ->
|
||||||
%Tesla.Env{status: 404, body: ""}
|
%Tesla.Env{status: 404, body: ""}
|
||||||
|
|
||||||
env ->
|
env ->
|
||||||
|
@ -145,6 +150,8 @@ test "returns the old object if refetch fails" do
|
||||||
updated_object = Object.get_by_id_and_maybe_refetch(object.id, interval: -1)
|
updated_object = Object.get_by_id_and_maybe_refetch(object.id, interval: -1)
|
||||||
assert Enum.at(updated_object.data["oneOf"], 0)["replies"]["totalItems"] == 4
|
assert Enum.at(updated_object.data["oneOf"], 0)["replies"]["totalItems"] == 4
|
||||||
assert Enum.at(updated_object.data["oneOf"], 1)["replies"]["totalItems"] == 0
|
assert Enum.at(updated_object.data["oneOf"], 1)["replies"]["totalItems"] == 0
|
||||||
|
end) =~
|
||||||
|
"[error] Couldn't refresh https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "does not refetch if the time since the last refetch is greater than the interval" do
|
test "does not refetch if the time since the last refetch is greater than the interval" do
|
||||||
|
|
Loading…
Reference in a new issue