refactor(config): remove environment variable prefix

This commit is contained in:
orhun 2021-07-24 23:51:23 +03:00
parent 411f278656
commit 97f47a5a42
No known key found for this signature in database
GPG key ID: F83424824B3E4B90

View file

@ -61,7 +61,7 @@ impl Config {
let mut config = config::Config::default(); let mut config = config::Config::default();
config config
.merge(config::File::with_name(file_name))? .merge(config::File::with_name(file_name))?
.merge(config::Environment::with_prefix(env!("CARGO_PKG_NAME")).separator("__"))?; .merge(config::Environment::new().separator("__"))?;
config.try_into() config.try_into()
} }
} }
@ -78,10 +78,7 @@ mod test {
.to_str() .to_str()
.unwrap() .unwrap()
.to_string(); .to_string();
env::set_var( env::set_var("SERVER__ADDRESS", "0.0.1.1");
format!("{}_SERVER__ADDRESS", env!("CARGO_PKG_NAME")),
"0.0.1.1",
);
let config = Config::parse(&file_name)?; let config = Config::parse(&file_name)?;
assert_eq!("0.0.1.1", config.server.address); assert_eq!("0.0.1.1", config.server.address);
Ok(()) Ok(())