1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.HTTPTest do
13 url: "http://example.com/hello",
14 headers: [{"content-type", "application/json"}]
16 json(%{"my" => "data"})
18 %{method: :get, url: "http://example.com/hello"} ->
19 %Tesla.Env{status: 200, body: "hello"}
21 %{method: :post, url: "http://example.com/world"} ->
22 %Tesla.Env{status: 200, body: "world"}
29 test "returns successfully result" do
30 assert Pleroma.HTTP.get("http://example.com/hello") == {
32 %Tesla.Env{status: 200, body: "hello"}
37 describe "get/2 (with headers)" do
38 test "returns successfully result for json content-type" do
39 assert Pleroma.HTTP.get("http://example.com/hello", [{"content-type", "application/json"}]) ==
44 body: "{\"my\":\"data\"}",
45 headers: [{"content-type", "application/json"}]
52 test "returns successfully result" do
53 assert Pleroma.HTTP.post("http://example.com/world", "") == {
55 %Tesla.Env{status: 200, body: "world"}