mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-27 19:09:12 +00:00
6cb40bee26
Closes #612 Co-authored-by: tusooa <tusooa@kazv.moe> Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/626 Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk> Co-committed-by: FloatingGhost <hannah@coffee-and-dreams.uk>
47 lines
1.4 KiB
Elixir
47 lines
1.4 KiB
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Integration.FederationTest do
|
|
use Pleroma.DataCase
|
|
@moduletag :federated
|
|
import Pleroma.Cluster
|
|
|
|
setup_all do
|
|
Pleroma.Cluster.spawn_default_cluster()
|
|
:ok
|
|
end
|
|
|
|
@federated1 :"federated1@127.0.0.1"
|
|
describe "federated cluster primitives" do
|
|
test "within/2 captures local bindings and executes block on remote node" do
|
|
captured_binding = :captured
|
|
|
|
result =
|
|
within @federated1 do
|
|
user = Pleroma.Factory.insert(:user)
|
|
{captured_binding, node(), user}
|
|
end
|
|
|
|
assert {:captured, @federated1, user} = result
|
|
refute Pleroma.User.get_by_id(user.id)
|
|
assert user.id == within(@federated1, do: Pleroma.User.get_by_id(user.id)).id
|
|
end
|
|
|
|
test "runs webserver on customized port" do
|
|
{nickname, url, url_404} =
|
|
within @federated1 do
|
|
user = Pleroma.Factory.insert(:user)
|
|
user_url = ~p[/api/v1/accounts/#{user}]
|
|
url_404 = ~p"/api/v1/accounts/not-exists"
|
|
|
|
{user.nickname, user_url, url_404}
|
|
end
|
|
|
|
assert {:ok, {{_, 200, _}, _headers, body}} = :httpc.request(~c"#{url}")
|
|
assert %{"acct" => ^nickname} = Jason.decode!(body)
|
|
assert {:ok, {{_, 404, _}, _headers, _body}} = :httpc.request(~c"#{url_404}")
|
|
end
|
|
end
|
|
end
|