use std::{collections::HashMap, ffi::OsString};
use super::discovery::EnvProvider;
#[derive(Default)]
pub(crate) struct TestEnv {
values: HashMap<&'static str, OsString>,
}
impl TestEnv {
pub(crate) fn with_var(mut self, name: &'static str, value: impl Into<OsString>) -> Self {
self.values.insert(name, value.into());
self
}
}
impl EnvProvider for TestEnv {
fn get(&self, key: &str) -> Option<OsString> {
self.values.get(key).cloned()
}
fn entries(&self) -> Vec<(OsString, OsString)> {
self.values
.iter()
.map(|(key, value)| (OsString::from(*key), value.clone()))
.collect()
}
}