test: add unit tests for environment variable bindings#747
Conversation
Adds coverage for all FACT_* env-var bindings in FactCli: - env_vars: each env var populates the correct FactConfig field - env_vars_override_yaml: env vars take precedence over YAML config - env_vars_invalid_values: invalid values produce ValueValidation errors Introduces EnvVar and EnvVarGuard helper types that together acquire ENV_MUTEX, set the variable, and guarantee removal on drop — even if the test panics. std::env::set_var is not safe in multi-threaded programs; the mutex serialises all env-var mutations within the suite as the least invasive available mitigation. Closes #730 Assisted-by: Claude Sonnet 4.6
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds concurrency-safe test infrastructure and three comprehensive test cases validating that environment variable bindings ( ChangesEnvironment Variable Test Coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Description
Adds coverage for all FACT_* env-var bindings in FactCli:
Introduces EnvVar and EnvVarGuard helper types that together acquire ENV_MUTEX, set the variable, and guarantee removal on drop — even if the test panics. std::env::set_var is not safe in multi-threaded programs; the mutex serialises all env-var mutations within the suite as the least invasive available mitigation.
Closes #730
Assisted-by: Claude Sonnet 4.6
Checklist
Automated testing
If any of these don't apply, please comment below.
Testing Performed
Run the tests manually.
Summary by CodeRabbit