Page MenuHomePhorge

No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/test/tesla/middleware/form_urlencoded_test.exs b/test/tesla/middleware/form_urlencoded_test.exs
index fadba6c..7bcb13f 100644
--- a/test/tesla/middleware/form_urlencoded_test.exs
+++ b/test/tesla/middleware/form_urlencoded_test.exs
@@ -1,61 +1,64 @@
defmodule Tesla.Middleware.FormUrlencodedTest do
use ExUnit.Case
defmodule Client do
use Tesla
plug Tesla.Middleware.FormUrlencoded
adapter fn env ->
{status, headers, body} =
case env.url do
"/post" ->
{201, [{"content-type", "text/html"}], env.body}
"/check_incoming_content_type" ->
{201, [{"content-type", "text/html"}], Tesla.get_header(env, "content-type")}
end
- %{env | status: status, headers: headers, body: body}
+ {:ok, %{env | status: status, headers: headers, body: body}}
end
end
test "encode body as application/x-www-form-urlencoded" do
- assert URI.decode_query(Client.post("/post", %{"foo" => "%bar "}).body) == %{"foo" => "%bar "}
+ assert {:ok, env} = Client.post("/post", %{"foo" => "%bar "})
+ assert URI.decode_query(env.body) == %{"foo" => "%bar "}
end
test "leave body alone if binary" do
- assert Client.post("/post", "data").body == "data"
+ assert {:ok, env} = Client.post("/post", "data")
+ assert env.body == "data"
end
test "check header is set as application/x-www-form-urlencoded" do
- assert Client.post("/check_incoming_content_type", %{"foo" => "%bar "}).body ==
- "application/x-www-form-urlencoded"
+ assert {:ok, env} = Client.post("/check_incoming_content_type", %{"foo" => "%bar "})
+ assert env.body == "application/x-www-form-urlencoded"
end
defmodule MultipartClient do
use Tesla
plug Tesla.Middleware.FormUrlencoded
adapter fn %{url: url, body: %Tesla.Multipart{}} = env ->
{status, headers, body} =
case url do
"/upload" ->
{200, [{"content-type", "text/html"}], "ok"}
end
- %{env | status: status, headers: headers, body: body}
+ {:ok, %{env | status: status, headers: headers, body: body}}
end
end
test "skips encoding multipart bodies" do
alias Tesla.Multipart
mp =
Multipart.new()
|> Multipart.add_field("param", "foo")
- assert MultipartClient.post("/upload", mp).body == "ok"
+ assert {:ok, env} = MultipartClient.post("/upload", mp)
+ assert env.body == "ok"
end
end

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 5:20 PM (23 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39035
Default Alt Text
(2 KB)

Event Timeline