Expand description
Process-env-or-injected-map abstraction for reads in production code.
Production code reads environment variables through
Context::env_var, which routes
through an injected EnvSource trait object. Production code uses
ProcessEnvSource (calls std::env::var); tests inject a
MapEnvSource via
TestContextBuilder::env
to drive deterministic branches without mutating the process env.
use anodizer_core::{EnvSource, MapEnvSource, ProcessEnvSource};
let prod = ProcessEnvSource;
let _ = prod.var("PATH");
let test_src = MapEnvSource::new()
.with("GITHUB_TOKEN", "ghp_synthetic")
.with("CI", "true");
assert_eq!(test_src.var("GITHUB_TOKEN"), Some("ghp_synthetic".to_string()));
assert_eq!(test_src.var("MISSING"), None);Structs§
- Layered
EnvSource - An
EnvSourcethat overlays a small map of override entries on top of a base source. - MapEnv
Source - Map-backed implementation for tests. Built from any
IntoIterator<Item=(K,V)>(includingHashMap<K, V>via theFromimpl below) or fluently viaMapEnvSource::with. - Process
EnvSource - Production implementation that reads
std::env::var.
Traits§
- EnvSource
- Read-only lookup for an environment variable name.