v0.1.4-pre.015-fix.002

This commit is contained in:
2026-08-16 18:20:32 +02:00
parent 05c65a12f4
commit 9ad61b40e1
25 changed files with 776 additions and 210 deletions

View File

@@ -1,19 +1,19 @@
// file: crates/ksp-app-config-desk/unit_tests/profiles.rs
// version: 1
// version: 2
#[test]
fn profile_inventory_exposes_logging_default_and_available_profiles() {
let management = committed_management();
assert!(management.is_ok(), "committed management should construct: {management:?}");
let management = fixture_management();
assert!(management.is_ok(), "fixture management should construct: {management:?}");
if let std::result::Result::Ok(management) = management {
let inventory = super::inventory_from_management(&management);
assert!(inventory.is_ok(), "profile inventory should resolve: {inventory:?}");
if let std::result::Result::Ok(inventory) = inventory {
assert_eq!(inventory.len(), 1);
assert_eq!(inventory[0].file_id, ksp_config_lib::FILE_ID_STD_LOGGING);
assert_eq!(inventory[0].default_profile, "local_dev");
assert!(!inventory[0].default_profile.is_empty());
assert!(inventory[0].profile_ids.iter().any(|profile_id| {
return profile_id == "local_dev";
return profile_id == &inventory[0].default_profile;
}));
}
}
@@ -21,13 +21,15 @@ fn profile_inventory_exposes_logging_default_and_available_profiles() {
#[test]
fn default_profile_detail_uses_safe_effective_value_and_dotenv_provenance() {
let management = committed_management();
assert!(management.is_ok(), "committed management should construct: {management:?}");
let management = fixture_management();
assert!(management.is_ok(), "fixture management should construct: {management:?}");
if let std::result::Result::Ok(management) = management {
let source = management.load_logging_document();
assert!(source.is_ok(), "typed Logging source should load: {source:?}");
let detail = super::detail_from_management(&management, ksp_config_lib::FILE_ID_STD_LOGGING, std::option::Option::None);
assert!(detail.is_ok(), "default profile should inspect safely: {detail:?}");
if let std::result::Result::Ok(detail) = detail {
assert_eq!(detail.selected_profile, "local_dev");
if let (std::result::Result::Ok(source), std::result::Result::Ok(detail)) = (source, detail) {
assert_eq!(detail.selected_profile, source.default_profile());
assert_eq!(detail.selection_source, "default_profile");
assert!(detail.value_origins.iter().any(|entry| {
return entry.key == "logs_directory" && entry.origin == "global";
@@ -45,21 +47,27 @@ fn default_profile_detail_uses_safe_effective_value_and_dotenv_provenance() {
#[test]
fn explicit_profile_inspection_reports_explicit_selection_source() {
let management = committed_management();
assert!(management.is_ok(), "committed management should construct: {management:?}");
let management = fixture_management();
assert!(management.is_ok(), "fixture management should construct: {management:?}");
if let std::result::Result::Ok(management) = management {
let detail = super::detail_from_management(&management, ksp_config_lib::FILE_ID_STD_LOGGING, std::option::Option::Some("local_dev"));
assert!(detail.is_ok(), "explicit profile should inspect: {detail:?}");
if let std::result::Result::Ok(detail) = detail {
assert_eq!(detail.selected_profile, "local_dev");
assert_eq!(detail.selection_source, "explicit");
let source = management.load_logging_document();
assert!(source.is_ok(), "typed Logging source should load: {source:?}");
if let std::result::Result::Ok(source) = source {
let profile_id = source.default_profile().to_owned();
let detail = super::detail_from_management(&management, ksp_config_lib::FILE_ID_STD_LOGGING, std::option::Option::Some(profile_id.as_str()));
assert!(detail.is_ok(), "explicit profile should inspect: {detail:?}");
if let std::result::Result::Ok(detail) = detail {
assert_eq!(detail.selected_profile, profile_id);
assert_eq!(detail.selection_source, "explicit");
}
}
}
}
fn committed_management() -> ksp_core_lib::Result<ksp_config_lib::ConfigManagement> {
fn fixture_management() -> ksp_core_lib::Result<ksp_config_lib::ConfigManagement> {
let workspace = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../..");
let bootstrap = ksp_config_lib::ConfigBootstrapOptions::from_paths(workspace.join("config"), workspace.join("config/schemas"));
let fixture_root = workspace.join("crates/ksp-config-lib/unit_tests/fixtures");
let bootstrap = ksp_config_lib::ConfigBootstrapOptions::from_paths(fixture_root, workspace.join("config/schemas"));
let bootstrap = match bootstrap {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => return std::result::Result::Err(error),