diff --git a/src/env.rs b/src/env.rs index 9792355ba..5eb06cc1a 100644 --- a/src/env.rs +++ b/src/env.rs @@ -1,15 +1,24 @@ +#[cfg(not(test))] use std::env; /// If `name` is set and, after trimming whitespace, is not empty string, then return that trimmed /// string. Else None. -pub fn get_env_var(name: &str) -> Option { - match env::var(name).unwrap_or_else(|_| "".to_string()).trim() { +pub fn get_env_var(_name: &str) -> Option { + #[cfg(not(test))] + match env::var(_name).unwrap_or_else(|_| "".to_string()).trim() { "" => None, non_empty_string => Some(non_empty_string.to_string()), } + #[cfg(test)] + None } /// If `name` is set to any value at all (including "") then return true; else false. -pub fn get_boolean_env_var(name: &str) -> bool { - env::var(name).ok().is_some() +pub fn get_boolean_env_var(_name: &str) -> bool { + #[cfg(not(test))] + { + env::var(_name).ok().is_some() + } + #[cfg(test)] + false }