v0.2.6-pre.003-fix.001
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-wallet-desk/tests/config_composition.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Config composition contracts introduced for Wallet Desk pre.003.
|
||||
|
||||
@@ -29,7 +29,8 @@ fn wallet_desk_composite_selects_logging_transport_and_wallet_by_file_id() {
|
||||
assert!(composite.is_ok(), "committed Wallet Desk composite should resolve: {composite:?}");
|
||||
if let std::result::Result::Ok(composite) = composite {
|
||||
assert_eq!(composite.profile_id(), "devnet");
|
||||
assert_component(&composite, "logging", ksp_config_lib::FILE_ID_STD_LOGGING, "local_dev");
|
||||
assert_component(&composite, "logging", ksp_config_lib::FILE_ID_STD_LOGGING, "wallet_desk_dev");
|
||||
assert_wallet_desk_logging_trace_profile(&composite);
|
||||
assert_component(&composite, "transport", ksp_config_lib::FILE_ID_STD_TRANSPORT, "devnet_public");
|
||||
assert_component(&composite, "wallet", ksp_config_lib::FILE_ID_STD_WALLET, "default");
|
||||
}
|
||||
@@ -37,6 +38,46 @@ fn wallet_desk_composite_selects_logging_transport_and_wallet_by_file_id() {
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_wallet_desk_logging_trace_profile(composite: &ksp_config_lib::ResolvedConfigComposite) {
|
||||
let component = composite.component("logging");
|
||||
assert!(component.is_some(), "missing logging component");
|
||||
if let std::option::Option::Some(component) = component {
|
||||
let profile = component.resolved().profile();
|
||||
assert_eq!(profile.get("default_filter").and_then(serde_json::Value::as_str), std::option::Option::Some("info"));
|
||||
let console = profile.get("console").and_then(serde_json::Value::as_object);
|
||||
let console_filter = console
|
||||
.and_then(|value| {
|
||||
return value.get("filter");
|
||||
})
|
||||
.and_then(serde_json::Value::as_object);
|
||||
let console_level = console_filter
|
||||
.and_then(|value| {
|
||||
return value.get("level");
|
||||
})
|
||||
.and_then(serde_json::Value::as_str);
|
||||
assert_eq!(console_level, std::option::Option::Some("trace"));
|
||||
let targets = console_filter
|
||||
.and_then(|value| {
|
||||
return value.get("targets");
|
||||
})
|
||||
.and_then(serde_json::Value::as_array);
|
||||
assert!(targets.is_some(), "Wallet Desk console targets should exist");
|
||||
if let std::option::Option::Some(targets) = targets {
|
||||
assert!(targets.iter().any(|target| -> bool {
|
||||
return target.as_str() == std::option::Option::Some("ksp-app-wallet-desk");
|
||||
}));
|
||||
}
|
||||
let target_filters = profile.get("target_filters").and_then(serde_json::Value::as_array);
|
||||
assert!(target_filters.is_some(), "Wallet Desk target filters should exist");
|
||||
if let std::option::Option::Some(target_filters) = target_filters {
|
||||
assert!(target_filters.iter().any(|filter| -> bool {
|
||||
return filter.get("target_prefix").and_then(serde_json::Value::as_str) == std::option::Option::Some("ksp-app-wallet-desk")
|
||||
&& filter.get("level").and_then(serde_json::Value::as_str) == std::option::Option::Some("trace");
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_component(composite: &ksp_config_lib::ResolvedConfigComposite, component_id: &str, file_id: &str, profile_id: &str) {
|
||||
let component = composite.component(component_id);
|
||||
assert!(component.is_some(), "missing component {component_id}");
|
||||
|
||||
Reference in New Issue
Block a user