mailchimp
mailchimp copied to clipboard
How do I test it?
Say I have the following setup in config/test.exs
config :mailchimp,
api_key: "your api-us10"
for every test, it is making a real call to Mailchimp. Is there a way to prevent it from sending real requests to Mailchimp?
@chungwong you can follow these guidelines http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/
@chungwong and anyone coming here in the future. The library now uses exvcr for testing. All the fixtures are included in the repo so testing is as easy as git pull mix test
@chungwong and anyone coming here in the future. The library now uses exvcr for testing. All the fixtures are included in the repo so testing is as easy as
git pullmix test
@ericdude4 but this is only for the internal tests of this package, right? This does not help me, when I use this package in my application and I want to test my integration is working. How would I test this?
@niklasmoeller Yes, this is for the internal tests of the package.
If you include this package in your application and write tests, it will make live requests to the Mailchimp API. For this reason, I would recommend using exvcr for your testing as well - unless you want the tests to always make live requests to the Mailchimp API 🤷♂
Another option is to replace Httpoison with Tesla and use provided mock facility.
Thanks @ericdude4. I will take a look into exvcr. This could be a good solution for this and other cases, too.