diff options
author | lain <lain@soykaf.club> | 2018-12-05 21:27:56 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2018-12-05 21:27:56 +0100 |
commit | 76d6b1c6ab2813b1fb8f4473e4d722cc32fb2fed (patch) | |
tree | 5308f2d4c169085dfbe22a95a86c5271e4285ace /test/http_test.exs | |
parent | 3ea4476445a5e9b6ec1625d7caa537f79254e9d0 (diff) | |
parent | 5f0c2372bc8be3763b649b13ee142c273583329e (diff) | |
download | pleroma-76d6b1c6ab2813b1fb8f4473e4d722cc32fb2fed.tar.gz pleroma-76d6b1c6ab2813b1fb8f4473e4d722cc32fb2fed.zip |
Merge remote-tracking branch 'origin' into follower-hiding
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 |