pub use std::env::VarError;
#[cfg(not(test))]
pub use std::env::var;
#[cfg(test)]
pub use fake_env::*;
#[cfg(test)]
mod fake_env {
use crate::std::cell::RefCell;
use crate::std::env::VarError;
use fakeenv::EnvStore;
thread_local! {
static ENV_STORE: RefCell<EnvStore> = RefCell::new({
let env = EnvStore::fake();
env.remove_var("ASSERTING_HIGHLIGHT_DIFFS");
env.remove_var("NO_COLOR");
env
});
}
pub fn var(key: &str) -> Result<String, VarError> {
ENV_STORE.with(|env| env.borrow().var(key))
}
pub fn set_var(key: &str, value: &str) {
ENV_STORE.with(|env| env.borrow_mut().set_var(key, value));
}
pub fn remove_var(key: &str) {
ENV_STORE.with(|env| env.borrow_mut().remove_var(key));
}
}