Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dlindenkreuz committed Jul 4, 2024
1 parent a8f606e commit f1af3af
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/req/steps_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,38 @@ defmodule Req.StepsTest do
end
end

test "zstd (content-type)" do
plug = fn conn ->
conn
|> Plug.Conn.put_resp_content_type("application/zstd", nil)
|> Plug.Conn.send_resp(200, :ezstd.compress("foo"))
end

assert Req.get!(plug: plug).body == "foo"
end

test "zstd (path)" do
plug = fn conn ->
conn
|> Plug.Conn.put_resp_content_type("application/octet-stream", nil)
|> Plug.Conn.send_resp(200, :ezstd.compress("foo"))
end

assert Req.get!(plug: plug, url: "/foo.zst").body == "foo"
end

test "zstd invalid" do
plug = fn conn ->
conn
|> Plug.Conn.put_resp_content_type("application/zstd", nil)
|> Plug.Conn.send_resp(200, "bad")
end

assert {:error, e} = Req.get(plug: plug)
assert match?(%RuntimeError{}, e)
assert Exception.message(e) == "Could not decompress Zstandard data: \"failed to decompress: ZSTD_CONTENTSIZE_ERROR\""
end

test "csv" do
csv = [
["x", "y"],
Expand Down

0 comments on commit f1af3af

Please sign in to comment.