//! Every fenced TOML example of `docs/configuration.md` loads as a `.botsecrets`, with //! unknown fields refused. A doc that shows a setting the code dropped fails here. use dirigent_fermata::core::secrets::config::SecretsConfig; fn toml_examples(doc: &str) -> Vec { let mut blocks = Vec::new(); let mut current: Option = None; for line in doc.lines() { match (&mut current, line.trim_end()) { (None, "```toml") => current = Some(String::new()), (Some(_), "```") => blocks.extend(current.take()), (Some(block), text) => { block.push_str(text); block.push('\n'); } _ => {} } } blocks } #[test] fn every_toml_example_of_configuration_md_loads() { let doc = include_str!("../docs/configuration.md"); let examples = toml_examples(doc); assert!(examples.len() >= 10, "found only {} TOML examples", examples.len()); for example in &examples { if let Err(error) = SecretsConfig::from_toml(example) { panic!("this example of configuration.md does not load: {error}\n{example}"); } } } /// The check has teeth: a removed setting is refused. #[test] fn a_removed_setting_does_not_load() { for text in ["[enforcement]\nmode = \"strict\"\n", "[enforcement]\non_parse_error = \"mask-entire-file\"\n"] { assert!(SecretsConfig::from_toml(text).is_err(), "{text}"); } }