Testing in a Phoenix App?
I'm relatively new to Elixir, so apologies if I'm missing something obvious. I have an httpoison client as a module in a Phoenix application. The client makes calls to an external API. I'm replacing the external api endpoint in tests using bypass, but am struggling to find a clean approach to doing so. Currently I set the external api endpoint in a config file. The api client module reads the endpoint from application config for each external api call. Any tests that need to bypass the actual endpoint replace the endpoint in application config and reset it after the test completes. It works, but just feels wrong to me.
I've thought about changing the api client to a GenServer that takes the endpoint as a param to start_link (as in the bypass readme examples)...but in the context of Phoenix, the GenServer will already be started by the time the tests start...which brings me back to a config-based approach.
Anyway, I know this is more of a StackOverflow question, but since I don't see much activity there re: bypass, I thought I would post here first. If this not appropriate for the issues board, just lmk and I will remove and repost on SO. Thanks for any guidance...