From 1be19a8a298aa0e25481491304e20322c85c97e7 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Fri, 18 Mar 2022 13:59:35 -0600 Subject: [PATCH] Update throttle test to reflect new behavior The "throttling" performed by Farside now redirects to the same instance as before, rather than outright blocking the connection. --- lib/farside/router.ex | 2 -- test/farside_test.exs | 13 +++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/farside/router.ex b/lib/farside/router.ex index f037ee2..2419055 100644 --- a/lib/farside/router.ex +++ b/lib/farside/router.ex @@ -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 diff --git a/test/farside_test.exs b/test/farside_test.exs index ff7ac35..05497f3 100644 --- a/test/farside_test.exs +++ b/test/farside_test.exs @@ -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