diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2018-12-06 20:15:16 +0700 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2018-12-06 20:15:16 +0700 |
commit | 4944498133d4a945650201226808b1f09d355014 (patch) | |
tree | 02e83bac731ca6b391b63d826d8230bdb0fdaed8 /test/http_test.exs | |
parent | bac58b152495c3ebf72e3ad1c3102de075fcc366 (diff) | |
parent | ccf0b46dd6a0390a06847b4a1c3eedc8d8e6c916 (diff) | |
download | pleroma-4944498133d4a945650201226808b1f09d355014.tar.gz pleroma-4944498133d4a945650201226808b1f09d355014.zip |
Merge branch 'develop' into feature/compat/push-subscriptions
# Conflicts:
# lib/pleroma/application.ex
# lib/pleroma/plugs/oauth_plug.ex
Diffstat (limited to 'test/http_test.exs')
-rw-r--r-- | test/http_test.exs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/http_test.exs b/test/http_test.exs new file mode 100644 index 000000000..62f3ccb30 --- /dev/null +++ b/test/http_test.exs @@ -0,0 +1,55 @@ +defmodule Pleroma.HTTPTest do + use Pleroma.DataCase + import Tesla.Mock + + setup do + mock(fn + %{ + method: :get, + url: "http://example.com/hello", + headers: [{"content-type", "application/json"}] + } -> + json(%{"my" => "data"}) + + %{method: :get, url: "http://example.com/hello"} -> + %Tesla.Env{status: 200, body: "hello"} + + %{method: :post, url: "http://example.com/world"} -> + %Tesla.Env{status: 200, body: "world"} + end) + + :ok + end + + describe "get/1" do + test "returns successfully result" do + assert Pleroma.HTTP.get("http://example.com/hello") == { + :ok, + %Tesla.Env{status: 200, body: "hello"} + } + end + end + + describe "get/2 (with headers)" do + test "returns successfully result for json content-type" do + assert Pleroma.HTTP.get("http://example.com/hello", [{"content-type", "application/json"}]) == + { + :ok, + %Tesla.Env{ + status: 200, + body: "{\"my\":\"data\"}", + headers: [{"content-type", "application/json"}] + } + } + end + end + + describe "post/2" do + test "returns successfully result" do + assert Pleroma.HTTP.post("http://example.com/world", "") == { + :ok, + %Tesla.Env{status: 200, body: "world"} + } + end + end +end |