changes
All checks were successful
CI / ci (push) Successful in 19m38s

This commit is contained in:
2026-08-26 20:55:30 +02:00
parent a557c183e9
commit 23d052278a
523 changed files with 24448 additions and 2005 deletions

View File

@@ -0,0 +1,47 @@
use figment::Jail;
use config::load;
const CONFIG_FILE: &str = "config.toml";
#[test]
fn a_malformed_file_is_refused_rather_than_ignored() {
Jail::expect_with(|jail| {
jail.create_file(CONFIG_FILE, "[server\nport = ")?;
assert!(load().is_err());
Ok(())
});
}
#[test]
fn a_value_of_the_wrong_type_is_refused() {
Jail::expect_with(|jail| {
jail.set_env("KMOOD_SERVER__PORT", "not-a-port");
assert!(load().is_err());
Ok(())
});
}
#[test]
fn a_refusal_names_the_key_at_fault() {
Jail::expect_with(|jail| {
jail.set_env("KMOOD_SERVER__PORT", "not-a-port");
let message = load().unwrap_err().to_string().to_lowercase();
assert!(message.contains("port"), "unhelpful message: {message}");
Ok(())
});
}
#[test]
fn a_named_file_that_is_missing_is_refused_rather_than_ignored() {
Jail::expect_with(|jail| {
jail.set_env("KMOOD_CONFIG_FILE", "nowhere.toml");
assert!(load().is_err());
Ok(())
});
}