elixirphoenix-frameworkhammer

Elixir-Phoenix: disable Hammer's rate limiting in testing


I need to disable rate limiting (or substantially increase the limit) in a Phoenix app for the test mode (because the tests exceed the limit). I use Hammer library for the rate limiting.

I'm looking for something other than checking for the test mode when serving a request.

(I couldn't find an answer either in the docs or in the example app's source.)

Thanks!


Solution

  • As suggested in Jonas Dellinger's comment to the question, I ended up setting the number of requests and a timescale in custom variables in /config/config.exs and /config/test.exs (ones in the latter "overwrite" values in the former in the test mode). I get these values for Hammer's check_rate/3 via Application.get_env/3.