v0.2.6-pre.003-fix.003

This commit is contained in:
2026-08-20 21:42:03 +02:00
parent 3fa4ab251a
commit 7eb0381932
9 changed files with 132 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-config-lib/unit_tests/document.rs
// version: 5
// version: 6
#[test]
fn committed_logging_document_passes_registered_schema_and_semantic_validation() {
@@ -49,15 +49,10 @@ fn committed_logging_document_exposes_reusable_operational_profiles() {
let profiles = document.value().get("profiles").and_then(serde_json::Value::as_array);
assert!(profiles.is_some(), "validated Logging document should retain profiles");
if let std::option::Option::Some(profiles) = profiles {
for profile_id in
["console_error", "console_warn", "console_info", "console_debug", "console_trace", "file_info", "local_dev", "superdev", "supertrace"]
{
assert!(
profiles.iter().any(|profile| -> bool {
return profile.get("profile_id").and_then(serde_json::Value::as_str) == std::option::Option::Some(profile_id);
}),
"committed Logging document is missing profile {profile_id}"
);
for profile_id in ["console_error", "console_warn", "console_info", "console_debug", "console_trace", "file_info", "local_dev", "superdev", "supertrace"] {
assert!(profiles.iter().any(|profile| -> bool {
return profile.get("profile_id").and_then(serde_json::Value::as_str) == std::option::Option::Some(profile_id);
}), "committed Logging document is missing profile {profile_id}");
}
assert_super_profile(profiles, "superdev", "debug");
assert_super_profile(profiles, "supertrace", "trace");
@@ -72,19 +67,18 @@ fn assert_super_profile(profiles: &[serde_json::Value], profile_id: &str, file_l
});
assert!(profile.is_some(), "missing super Logging profile {profile_id}");
if let std::option::Option::Some(profile) = profile {
let console_level =
profile.get("console").and_then(|value| value.get("filter")).and_then(|value| value.get("level")).and_then(serde_json::Value::as_str);
let console_level = profile
.get("console")
.and_then(|value| { return value.get("filter"); })
.and_then(|value| { return value.get("level"); })
.and_then(serde_json::Value::as_str);
assert_eq!(console_level, std::option::Option::Some("debug"));
let files = profile.get("files").and_then(serde_json::Value::as_array);
assert_eq!(files.map(std::vec::Vec::len), std::option::Option::Some(7));
if let std::option::Option::Some(files) = files {
assert!(
files.iter().all(|file| -> bool {
return file.get("filter").and_then(|value| value.get("level")).and_then(serde_json::Value::as_str)
== std::option::Option::Some(file_level);
}),
"all {profile_id} file sinks should use level {file_level}"
);
assert!(files.iter().all(|file| -> bool {
return file.get("filter").and_then(|value| { return value.get("level"); }).and_then(serde_json::Value::as_str) == std::option::Option::Some(file_level);
}), "all {profile_id} file sinks should use level {file_level}");
}
}
}