TemporaryEnv v2.0.0 TemporaryEnv

Temporarily set Application environment variables.

Quite handy for testing, but remember to set async: false for tests suites it is used in.

Summary

Functions

Temporarily unset an Application environment value within a block

Temporarily set an Application environment value within a block

Functions

delete(app, key, list) (macro)

Temporarily unset an Application environment value within a block.

TemporaryEnv.delete :my_app, :greeting do
  # :greeting for :my_app now has no value
end
# :greeting for :my_app is back to its original value

This does modify global state, so do not use it in an async situation.

put(app, key, value, list) (macro)
put(term, atom, atom, any, [{:do, any}]) :: any

Temporarily set an Application environment value within a block.

TemporaryEnv.put :my_app, :greeting, "Hello!" do
  # :greeting for :my_app is now "Hello!"
end
# :greeting for :my_app is back to its original value

This does modify global state, so do not use it in an async situation.