v0.1.4-pre.016
This commit is contained in:
23
crates/ksp-logging-lib/unit_tests/identity.rs
Normal file
23
crates/ksp-logging-lib/unit_tests/identity.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
// 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());
|
||||
}
|
||||
Reference in New Issue
Block a user