1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.HTTPTest do
6 use ExUnit.Case, async: true
7 use Pleroma.Tests.Helpers
15 url: "http://example.com/hello",
16 headers: [{"content-type", "application/json"}]
18 json(%{"my" => "data"})
20 %{method: :get, url: "http://example.com/hello"} ->
21 %Tesla.Env{status: 200, body: "hello"}
23 %{method: :post, url: "http://example.com/world"} ->
24 %Tesla.Env{status: 200, body: "world"}
31 test "returns successfully result" do
32 assert HTTP.get("http://example.com/hello") == {
34 %Tesla.Env{status: 200, body: "hello"}
39 describe "get/2 (with headers)" do
40 test "returns successfully result for json content-type" do
41 assert HTTP.get("http://example.com/hello", [{"content-type", "application/json"}]) ==
46 body: "{\"my\":\"data\"}",
47 headers: [{"content-type", "application/json"}]
54 test "returns successfully result" do
55 assert HTTP.post("http://example.com/world", "") == {
57 %Tesla.Env{status: 200, body: "world"}