Skip to content

Commit

Permalink
Added tests for raise, throw and exit situations.
Browse files Browse the repository at this point in the history
  • Loading branch information
emerleite committed Oct 6, 2017
1 parent d4414d0 commit 835295e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/tesla/middleware/timeout_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ defmodule Tesla.Middleware.TimeoutTest do
"/sleep_150ms" ->
Process.sleep(150)
200
"/raise" ->
raise "custom_exception"
"/throw" ->
throw(:throw_value)
"/exit" ->
exit(:exit_value)
end

%{env | status: status}
Expand Down Expand Up @@ -64,4 +70,20 @@ defmodule Tesla.Middleware.TimeoutTest do
assert %Tesla.Env{status: 200} = DefaultTimeoutClient.get("/sleep_950ms")
end
end

describe "repassing errors and exit" do
test "should repass rescued errors" do
assert_raise RuntimeError, "custom_exception", fn ->
Client.get("/raise")
end
end

test "should repass thrown value" do
assert catch_throw(Client.get("/throw")) == :throw_value
end

test "should repass exit value" do
assert catch_exit(Client.get("/exit")) == :exit_value
end
end
end

0 comments on commit 835295e

Please sign in to comment.