pub struct MockEnvProvider { /* private fields */ }Expand description
Mock environment provider for testing.
Records which variables were accessed, useful for verifying that functions read the expected environment variables.
Implementations§
Source§impl MockEnvProvider
impl MockEnvProvider
Sourcepub fn with_vars(vars: HashMap<String, String>) -> Self
pub fn with_vars(vars: HashMap<String, String>) -> Self
Create a mock provider with the given variables.
Sourcepub fn set(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn set(&mut self, key: impl Into<String>, value: impl Into<String>)
Set an environment variable.
Sourcepub fn accessed_keys(&self) -> Vec<String>
pub fn accessed_keys(&self) -> Vec<String>
Get list of accessed variable names.
Sourcepub fn was_accessed(&self, key: &str) -> bool
pub fn was_accessed(&self, key: &str) -> bool
Check if a specific key was accessed.
Sourcepub fn clear_accessed(&self)
pub fn clear_accessed(&self)
Clear the accessed keys list.
Sourcepub fn assert_accessed(&self, key: &str)
pub fn assert_accessed(&self, key: &str)
Assert that a specific key was accessed.
Sourcepub fn assert_not_accessed(&self, key: &str)
pub fn assert_not_accessed(&self, key: &str)
Assert that a specific key was NOT accessed.
Trait Implementations§
Source§impl Clone for MockEnvProvider
impl Clone for MockEnvProvider
Source§fn clone(&self) -> MockEnvProvider
fn clone(&self) -> MockEnvProvider
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MockEnvProvider
impl Debug for MockEnvProvider
Source§impl Default for MockEnvProvider
impl Default for MockEnvProvider
Source§fn default() -> MockEnvProvider
fn default() -> MockEnvProvider
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MockEnvProvider
impl RefUnwindSafe for MockEnvProvider
impl Send for MockEnvProvider
impl Sync for MockEnvProvider
impl Unpin for MockEnvProvider
impl UnwindSafe for MockEnvProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more