Files
2026-08-16 19:00:49 +02:00

24 lines
1.0 KiB
Rust

// file: crates/ksp-logging-lib/unit_tests/identity.rs
// version: 1
#[test]
fn runtime_identity_accepts_safe_application_and_timestamp_tokens() {
let identity = crate::LoggingRuntimeIdentity::new("ksp-app-config-desk", "20260816-182519.123-p4242");
assert!(identity.is_ok());
if let std::result::Result::Ok(identity) = identity {
assert_eq!(identity.application_id(), "ksp-app-config-desk");
assert_eq!(identity.launch_timestamp(), "20260816-182519.123-p4242");
assert_eq!(identity.file_name_prefix("ksp-debug.log"), "ksp-app-config-desk.20260816-182519.123-p4242.ksp-debug.log");
}
}
#[test]
fn runtime_identity_rejects_paths_whitespace_and_empty_components() {
for application_id in ["", "ksp app", "../ksp-app", "ksp/app"] {
let result = crate::LoggingRuntimeIdentity::new(application_id, "20260816-182519.123-p4242");
assert!(result.is_err());
}
let result = crate::LoggingRuntimeIdentity::new("ksp-app-config-desk", "2026/08/16");
assert!(result.is_err());
}