config: add failing tests for load, resolution, defaults, masking

Tests define the API for the config module:
- Config::load_with(path, home) / Config::load(path) read the TOML file
  (database/web/state/backup sections per config.template.toml)
- empty strings resolve to built-in defaults: db port 3306, web port
  8080, state dir $HOME/.config/rpn, backup dir <state>/backups
  (backup follows an explicitly set state dir)
- port may be written as a TOML int or a string in real configs;
  non-numeric strings are a ConfigError
- resolve_config_path(): --config flag > $RUSTYRPN_CONFIG >
  cwd/config.toml; --env=dev|test only affects that last default slot
- Config::show() renders the effective config with the password masked
- Config::validate_database() requires host/user/name

Also adds the toml crate (forced by the TOML config decision).
This commit is contained in:
2026-09-08 18:17:00 +02:00
parent e81ef6b351
commit a81dd6f543
4 changed files with 225 additions and 0 deletions
+31
View File
@@ -1272,6 +1272,7 @@ dependencies = [
"tempfile",
"thiserror",
"tokio",
"toml",
"tracing",
]
@@ -1386,6 +1387,15 @@ dependencies = [
"zmij",
]
[[package]]
name = "serde_spanned"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
dependencies = [
"serde_core",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -1861,6 +1871,21 @@ dependencies = [
"tokio",
]
[[package]]
name = "toml"
version = "1.1.5+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12c0ba9680044b4ce98d391a62094047eada0d64860b80166c39f4a6b5640785"
dependencies = [
"indexmap",
"serde_core",
"serde_spanned",
"toml_datetime",
"toml_parser",
"toml_writer",
"winnow",
]
[[package]]
name = "toml_datetime"
version = "1.1.1+spec-1.1.0"
@@ -1891,6 +1916,12 @@ dependencies = [
"winnow",
]
[[package]]
name = "toml_writer"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
[[package]]
name = "tracing"
version = "0.1.44"