Settings test: inject the env probe instead of mutating the environment

The env-detection test briefly set a real DAILY_EPUB_* variable, which raced
with the config test that loads the shipped example through figment.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NHyYupFdBiR4VfoUM7NjSM
This commit is contained in:
2026-09-03 17:53:47 +00:00
co-authored by Claude Fable 5.1
parent 073a85f3c7
commit d404946c78
+4 -10
View File
@@ -1834,16 +1834,10 @@ mod tests {
env_name("providers.gemini.api_key"), env_name("providers.gemini.api_key"),
ProviderConfig::api_key_env_var("gemini") ProviderConfig::api_key_env_var("gemini")
); );
let previous = std::env::var_os(name); // Never mutate the process environment here: other tests load the
// SAFETY: the variable is unique to this test, holds the default // shipped config through figment concurrently and would see the
// value so a concurrent `Config::load` sees no change, and is // variable. The probe is injected instead.
// restored before the assertions. let groups = schema_with_env(&Config::default(), None, &|var| var == name);
unsafe { std::env::set_var(name, "180") };
let groups = schema(&Config::default(), None);
match previous {
Some(value) => unsafe { std::env::set_var(name, value) },
None => unsafe { std::env::remove_var(name) },
}
assert_eq!( assert_eq!(
field(&groups, "curation.ranking.telemetry_retention_days").source, field(&groups, "curation.ranking.telemetry_retention_days").source,
Source::Env(name.to_string()) Source::Env(name.to_string())