From d404946c783a4dc87f84f519ce7f4ae6057860bd Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Thu, 3 Sep 2026 17:53:47 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01NHyYupFdBiR4VfoUM7NjSM --- src/web/dashboard/settings.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/web/dashboard/settings.rs b/src/web/dashboard/settings.rs index 7c71cec..1d4402a 100644 --- a/src/web/dashboard/settings.rs +++ b/src/web/dashboard/settings.rs @@ -1834,16 +1834,10 @@ mod tests { env_name("providers.gemini.api_key"), ProviderConfig::api_key_env_var("gemini") ); - let previous = std::env::var_os(name); - // SAFETY: the variable is unique to this test, holds the default - // value so a concurrent `Config::load` sees no change, and is - // restored before the assertions. - 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) }, - } + // Never mutate the process environment here: other tests load the + // shipped config through figment concurrently and would see the + // variable. The probe is injected instead. + let groups = schema_with_env(&Config::default(), None, &|var| var == name); assert_eq!( field(&groups, "curation.ranking.telemetry_retention_days").source, Source::Env(name.to_string())