Skip to content

Commit

Permalink
Update throttle test to reflect new behavior
Browse files Browse the repository at this point in the history
The "throttling" performed by Farside now redirects to the same instance
as before, rather than outright blocking the connection.
  • Loading branch information
benbusby committed Mar 18, 2022
1 parent 22e9135 commit 1be19a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions lib/farside/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ defmodule Farside.Router do
true ->
Farside.pick_instance(service)
end
IO.inspect(get_req_header(conn, "throttle"))
IO.inspect(instance)

params =
cond do
Expand Down
13 changes: 9 additions & 4 deletions test/farside_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ defmodule FarsideTest do
end

test "throttle" do
:get
|> conn("/", "")
|> Router.call(@opts)
first_conn =
:get
|> conn("/", "")
|> Router.call(@opts)

first_redirect = elem(List.last(first_conn.resp_headers), 1)

throttled_conn =
:get
|> conn("/", "")
|> Router.call(@opts)

throttled_redirect = elem(List.last(first_conn.resp_headers), 1)

assert throttled_conn.state == :sent
assert throttled_conn.status == 403
assert throttled_redirect == first_redirect
end

test "/" do
Expand Down

0 comments on commit 1be19a8

Please sign in to comment.