I’m trying to come up with a way to test configuration files for my app. The app config has several optional attributes for specifying location such as latitude and longitude coordinates or city/region/country names/codes. If no location is specified it has a fallback method for finding location of local machine based on ipinfo.io.
I have a default configuration in place but this only allows me to test the attribute set in that file. I’d like to have the ability to specify the path in the testing env such that I could use a different config file to test each of the optional attributes, including the situation where no location attribute is set.
My current configuration API just calls MyApp.Config.load_config()
with no arguments. The reason for this is I have a cascading set of configuration sources: default config file (. /config/config.toml
), system ENV variables, installed system-wide config file (/etc/myapp/config.toml
in Linux), installed user config file (/home/$USER/.config/myapp/config.toml
). Each source overwrites any previously set attributes.