Open silicium14 opened 5 years ago
I had a similar issue and managed to resolve it by adding a Bypass.pass(bypass)
call just prior to my assertion (or just before the end of the test). It's kind of a work around, I think, but it solved my issue. So, using your example, maybe this would work:
@tag timeout: 2000
test "bypass with hackney" do
...
assert result == {:error, :timeout}
# Clear any expectation of bypassed requests completing
Bypass.pass(bypass)
IO.puts "DEBUG: End of test reached"
end
I want to test that I'm able to abort a request that takes too long for any reason. I decided to use a task to wrap my request, the task is shut down after a timeout. I use bypass in my test to simulate a request that takes longer than the timeout value.
When using httpc to make the request the test succeeds. When using hackney to make the request, the test hangs in
Bypass.do_verify_expectations/2
.I use
{:hackney, "~> 1.15"}
and{:bypass, "~> 1.0.0", only: :test}
. Below is the test runner output and the code for the two tests.