aboutsummaryrefslogtreecommitdiff
path: root/test/http/request_builder_test.exs
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-11-12 12:34:48 +0000
committerrinpatch <rinpatch@sdf.org>2020-11-12 12:34:48 +0000
commit1172844ed18d94d84724dc6f11c6e9f72e0ba6ec (patch)
tree7d48a259e08856ab6db0eba255f20c0c19410463 /test/http/request_builder_test.exs
parenta0f5e8b27edbe2224d9c2c3997ad5b8ea484244b (diff)
parentb4c6b262d6dc12362f0014a864e8aed6c727c39c (diff)
downloadpleroma-2.2.0.tar.gz
Merge branch 'release/2.2.0' into 'stable'v2.2.0
Release/2.2.0 See merge request pleroma/secteam/pleroma!19
Diffstat (limited to 'test/http/request_builder_test.exs')
-rw-r--r--test/http/request_builder_test.exs85
1 files changed, 0 insertions, 85 deletions
diff --git a/test/http/request_builder_test.exs b/test/http/request_builder_test.exs
deleted file mode 100644
index fab909905..000000000
--- a/test/http/request_builder_test.exs
+++ /dev/null
@@ -1,85 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.HTTP.RequestBuilderTest do
- use ExUnit.Case
- use Pleroma.Tests.Helpers
- alias Pleroma.HTTP.Request
- alias Pleroma.HTTP.RequestBuilder
-
- describe "headers/2" do
- test "don't send pleroma user agent" do
- assert RequestBuilder.headers(%Request{}, []) == %Request{headers: []}
- end
-
- test "send pleroma user agent" do
- clear_config([:http, :send_user_agent], true)
- clear_config([:http, :user_agent], :default)
-
- assert RequestBuilder.headers(%Request{}, []) == %Request{
- headers: [{"user-agent", Pleroma.Application.user_agent()}]
- }
- end
-
- test "send custom user agent" do
- clear_config([:http, :send_user_agent], true)
- clear_config([:http, :user_agent], "totally-not-pleroma")
-
- assert RequestBuilder.headers(%Request{}, []) == %Request{
- headers: [{"user-agent", "totally-not-pleroma"}]
- }
- end
- end
-
- describe "add_param/4" do
- test "add file parameter" do
- %Request{
- body: %Tesla.Multipart{
- boundary: _,
- content_type_params: [],
- parts: [
- %Tesla.Multipart.Part{
- body: %File.Stream{
- line_or_bytes: 2048,
- modes: [:raw, :read_ahead, :read, :binary],
- path: "some-path/filename.png",
- raw: true
- },
- dispositions: [name: "filename.png", filename: "filename.png"],
- headers: []
- }
- ]
- }
- } = RequestBuilder.add_param(%Request{}, :file, "filename.png", "some-path/filename.png")
- end
-
- test "add key to body" do
- %{
- body: %Tesla.Multipart{
- boundary: _,
- content_type_params: [],
- parts: [
- %Tesla.Multipart.Part{
- body: "\"someval\"",
- dispositions: [name: "somekey"],
- headers: [{"content-type", "application/json"}]
- }
- ]
- }
- } = RequestBuilder.add_param(%{}, :body, "somekey", "someval")
- end
-
- test "add form parameter" do
- assert RequestBuilder.add_param(%{}, :form, "somename", "someval") == %{
- body: %{"somename" => "someval"}
- }
- end
-
- test "add for location" do
- assert RequestBuilder.add_param(%{}, :some_location, "somekey", "someval") == %{
- some_location: [{"somekey", "someval"}]
- }
- end
- end
-end