X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fhttp%2Frequest_builder_test.exs;h=fab909905d133936d186bf0d754ffcb65043c01c;hb=6b84c62d4a51cb17192945d1b67999b2c56a23d2;hp=113158c9fffcba538b6655b1f994c24205c8921b;hpb=c69b04c49090c5d86af2e9609d0b45d091f09267;p=akkoma
diff --git a/test/http/request_builder_test.exs b/test/http/request_builder_test.exs
index 113158c9f..fab909905 100644
--- a/test/http/request_builder_test.exs
+++ b/test/http/request_builder_test.exs
@@ -1,59 +1,40 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.RequestBuilderTest do
- use ExUnit.Case, async: true
+ use ExUnit.Case
use Pleroma.Tests.Helpers
+ alias Pleroma.HTTP.Request
alias Pleroma.HTTP.RequestBuilder
describe "headers/2" do
- clear_config([:http, :send_user_agent])
- clear_config([:http, :user_agent])
-
test "don't send pleroma user agent" do
- assert RequestBuilder.headers(%{}, []) == %{headers: []}
+ assert RequestBuilder.headers(%Request{}, []) == %Request{headers: []}
end
test "send pleroma user agent" do
- Pleroma.Config.put([:http, :send_user_agent], true)
- Pleroma.Config.put([:http, :user_agent], :default)
+ clear_config([:http, :send_user_agent], true)
+ clear_config([:http, :user_agent], :default)
- assert RequestBuilder.headers(%{}, []) == %{
- headers: [{"User-Agent", Pleroma.Application.user_agent()}]
+ assert RequestBuilder.headers(%Request{}, []) == %Request{
+ headers: [{"user-agent", Pleroma.Application.user_agent()}]
}
end
test "send custom user agent" do
- Pleroma.Config.put([:http, :send_user_agent], true)
- Pleroma.Config.put([:http, :user_agent], "totally-not-pleroma")
+ clear_config([:http, :send_user_agent], true)
+ clear_config([:http, :user_agent], "totally-not-pleroma")
- assert RequestBuilder.headers(%{}, []) == %{
- headers: [{"User-Agent", "totally-not-pleroma"}]
+ assert RequestBuilder.headers(%Request{}, []) == %Request{
+ headers: [{"user-agent", "totally-not-pleroma"}]
}
end
end
- describe "add_optional_params/3" do
- test "don't add if keyword is empty" do
- assert RequestBuilder.add_optional_params(%{}, %{}, []) == %{}
- end
-
- test "add query parameter" do
- assert RequestBuilder.add_optional_params(
- %{},
- %{query: :query, body: :body, another: :val},
- [
- {:query, "param1=val1¶m2=val2"},
- {:body, "some body"}
- ]
- ) == %{query: "param1=val1¶m2=val2", body: "some body"}
- end
- end
-
describe "add_param/4" do
test "add file parameter" do
- %{
+ %Request{
body: %Tesla.Multipart{
boundary: _,
content_type_params: [],
@@ -70,7 +51,7 @@ defmodule Pleroma.HTTP.RequestBuilderTest do
}
]
}
- } = RequestBuilder.add_param(%{}, :file, "filename.png", "some-path/filename.png")
+ } = RequestBuilder.add_param(%Request{}, :file, "filename.png", "some-path/filename.png")
end
test "add key to body" do
@@ -82,7 +63,7 @@ defmodule Pleroma.HTTP.RequestBuilderTest do
%Tesla.Multipart.Part{
body: "\"someval\"",
dispositions: [name: "somekey"],
- headers: ["Content-Type": "application/json"]
+ headers: [{"content-type", "application/json"}]
}
]
}