Check profile in jail to avoid env races.

This commit is contained in:
Sergio Benitez 2021-02-19 12:49:39 -08:00
parent e4c2324bab
commit aaea84d750
1 changed files with 17 additions and 13 deletions

View File

@ -131,26 +131,30 @@ mod tests {
#[test]
fn test_default_round_trip() {
let figment = Figment::from(Config::default());
figment::Jail::expect_with(|_| {
let figment = Figment::from(Config::default());
assert_eq!(figment.profile(), Config::DEFAULT_PROFILE);
assert_eq!(figment.profile(), Config::DEFAULT_PROFILE);
#[cfg(debug_assertions)]
assert_eq!(figment.profile(), Config::DEBUG_PROFILE);
#[cfg(debug_assertions)]
assert_eq!(figment.profile(), Config::DEBUG_PROFILE);
#[cfg(not(debug_assertions))]
assert_eq!(figment.profile(), Config::RELEASE_PROFILE);
#[cfg(not(debug_assertions))]
assert_eq!(figment.profile(), Config::RELEASE_PROFILE);
let config: Config = figment.extract().unwrap();
assert_eq!(config, Config::default());
let config: Config = figment.extract().unwrap();
assert_eq!(config, Config::default());
#[cfg(debug_assertions)]
assert_eq!(config, Config::debug_default());
#[cfg(debug_assertions)]
assert_eq!(config, Config::debug_default());
#[cfg(not(debug_assertions))]
assert_eq!(config, Config::release_default());
#[cfg(not(debug_assertions))]
assert_eq!(config, Config::release_default());
assert_eq!(Config::from(Config::default()), Config::default());
assert_eq!(Config::from(Config::default()), Config::default());
Ok(())
});
}
#[test]