test(backent): fix ActivityPub client mock
This commit is contained in:
@@ -50,13 +50,16 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.FollowTest do
|
||||
|> Jason.decode!()
|
||||
|
||||
Mock
|
||||
|> expect(:call, fn
|
||||
|> expect(:call, 2, fn
|
||||
%{method: :get, url: "https://social.tcit.fr/users/tcit"}, _opts ->
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: Map.put(actor_data, "id", "https://social.tcit.fr/users/tcit")
|
||||
}}
|
||||
|
||||
%{method: :post, url: "https://framapiaf.org/inbox"} = args, _opts ->
|
||||
{:ok, args}
|
||||
end)
|
||||
|
||||
data =
|
||||
|
||||
@@ -62,9 +62,12 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.UndoTest do
|
||||
|> Map.put("id", "https://social.tcit.fr/users/tcit")
|
||||
|
||||
Mock
|
||||
|> expect(:call, fn
|
||||
|> expect(:call, 2, fn
|
||||
%{method: :get, url: "https://social.tcit.fr/users/tcit"}, _opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: actor_data}}
|
||||
|
||||
%{method: :post, url: "https://framapiaf.org/inbox"} = args, _opts ->
|
||||
{:ok, args}
|
||||
end)
|
||||
|
||||
{:ok, %Activity{data: _, local: false}, _} = Transmogrifier.handle_incoming(follow_data)
|
||||
|
||||
@@ -185,6 +185,12 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.UpdateTest do
|
||||
|> Map.put("actor", remote_actor_url)
|
||||
|> Map.put("object", object)
|
||||
|
||||
Mock
|
||||
|> expect(:call, 2, fn
|
||||
%{method: :post, url: "http://mobilizon.test/inbox"}, _opts ->
|
||||
{:ok, %Tesla.Env{status: 200, body: update_data}}
|
||||
end)
|
||||
|
||||
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(update_data)
|
||||
|
||||
%Post{id: updated_post_id, title: updated_post_title} =
|
||||
|
||||
Reference in New Issue
Block a user