mathieuprog / tz

Time zone support for Elixir
Apache License 2.0
125 stars 11 forks source link

Question: avoid compile on unit test but keep update in app #4

Closed jpcaruana closed 3 years ago

jpcaruana commented 3 years ago

Hi,

I followed your Readme and configured my app to auto-update data. In the end, I had to remove it since it would always compile when I run mix test: it adds a lot of significant time (and to me was not worth it)

Is there a way to enable auto-update for data within my app (in production for instance) but not when running unit tests ?

Thanks

mathieuprog commented 3 years ago

Hi Jean-Philippe 👋

I added a way to achieve this under this section: https://github.com/mathieuprog/tz#automatic-time-zone-data-updates

What do you think?

jpcaruana commented 3 years ago

Hey @mathieuprog

thanks for the documentation improvement (I think I could have done this myself... shame on me): it does the trick!

I had an error with the :calendar_storefront part in your doc: I copied it without thinking (just follow the example) but I had a red warning (didn't make my test suite fail though):

You have configured application :calendar_storefront in your configuration file,
but the application is not available.

This usually means one of:

  1. You have not added the application as a dependency in a mix.exs file.

  2. You are configuring an application that does not really exist.

Please ensure :calendar_storefront exists or remove the configuration.

so I removed config :calendar_storefront, env: Mix.env() from my config.exs

mathieuprog commented 3 years ago

Whoops! That's the name of my app haha. I corrected the Readme file. You should replace with your app name:

config :my_app, env: Mix.env()

Same for:

|> append_if(Application.get_env(:my_app, :env) != :test, {Tz.UpdatePeriodically, []})

Replace :my_app by your app name as you usually do in your config.exs file.

mathieuprog commented 3 years ago

If you have any other questions feel free to ask! I'll close this issue now.

Btw thanks for bringing this up, I updated my own app with this code as I was having the same issue 😄

jpcaruana commented 3 years ago

Yes :my_app is self explanatory :) Thanks for the follow up!