Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed May 28, 2024
1 parent a6d3fc6 commit e19ee81
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions test/req_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,13 @@ defmodule ReqTest do
conn
end)

%{url: proxy_url} =
%{url: echo_url} =
start_server(fn conn ->
%{status: 200, body: async} = Req.get!(url: origin_url, into: :self, retry: false)

conn = Plug.Conn.send_chunked(conn, 200)
assert_received {:plug_conn, :sent}

Enum.reduce(async, conn, &chunk(&2, &1))
{:ok, body, conn} = Plug.Conn.read_body(conn)
Plug.Conn.send_resp(conn, 200, body)
end)

assert Req.get!(proxy_url, into: []).body == ~w[foo bar baz]
end

defp chunk(conn, data) do
{:ok, conn} = Plug.Conn.chunk(conn, data)
conn
resp = Req.get!(origin_url, into: :self)
assert Req.put!(echo_url, body: resp.body).body == "foobarbaz"
end
end

0 comments on commit e19ee81

Please sign in to comment.