Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Aug 30, 2023
1 parent 4373834 commit e9401b1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
MIX_ENV: test
# TODO: Remove on Req 1.0
REQ_NOWARN_OUTPUT: true
# TODO: Remove on next finch
FINCH_REF: main
strategy:
fail-fast: false
matrix:
Expand Down
6 changes: 3 additions & 3 deletions lib/req/steps.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ defmodule Req.Steps do
{:ok, decompressed} = :brotli.decode(body)
decompress_body(rest, decompressed, acc)
else
Logger.debug("decompress_body: :brotli library not loaded, skipping brotli decompression")
Logger.debug(":brotli library not loaded, skipping brotli decompression")
decompress_body(rest, body, ["br" | acc])
end
end
Expand All @@ -1122,7 +1122,7 @@ defmodule Req.Steps do
if ezstd_loaded?() do
decompress_body(rest, :ezstd.decompress(body), acc)
else
Logger.debug("decompress_body: :ezstd library not loaded, skipping zstd decompression")
Logger.debug(":ezstd library not loaded, skipping zstd decompression")
decompress_body(rest, body, ["zstd" | acc])
end
end
Expand All @@ -1132,7 +1132,7 @@ defmodule Req.Steps do
end

defp decompress_body([codec | rest], body, acc) do
Logger.debug("decompress_body: algorithm #{inspect(codec)} is not supported")
Logger.debug("algorithm #{inspect(codec)} is not supported")
decompress_body(rest, body, [codec | acc])
end

Expand Down
10 changes: 7 additions & 3 deletions test/req/steps_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,13 @@ defmodule Req.StepsTest do
|> Plug.Conn.send_resp(200, body)
end

assert Req.get!("", plug: plug).body |> :zlib.uncompress() |> Jason.decode!() == %{
"a" => 1
}
{resp, log} =
ExUnit.CaptureLog.with_log(fn ->
Req.get!("", plug: plug)
end)

assert resp.body |> :zlib.uncompress() |> Jason.decode!() == %{"a" => 1}
assert log =~ ~s|algorithm \"deflate\" is not supported|
end

describe "redirect" do
Expand Down
12 changes: 9 additions & 3 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ defmodule TestServer do
end

defp accept(listen_socket, fun) do
{:ok, socket} = :gen_tcp.accept(listen_socket)
fun.(socket)
:ok = :gen_tcp.close(socket)
case :gen_tcp.accept(listen_socket) do
{:ok, socket} ->
fun.(socket)
:ok = :gen_tcp.close(socket)

{:error, :closed} ->
:ok
end

accept(listen_socket, fun)
end
end
Expand Down

0 comments on commit e9401b1

Please sign in to comment.