Files
k-photos/crates/domain/tests/common/value_objects/system_id.rs

32 lines
675 B
Rust

use domain::value_objects::SystemId;
use uuid::Uuid;
#[test]
fn unique_generation() {
let a = SystemId::new();
let b = SystemId::new();
assert_ne!(a, b);
}
#[test]
fn uuid_roundtrip() {
let uuid = Uuid::new_v4();
let id = SystemId::from_uuid(uuid);
assert_eq!(*id.as_uuid(), uuid);
}
#[test]
fn display_matches_uuid() {
let uuid = Uuid::new_v4();
let id = SystemId::from_uuid(uuid);
assert_eq!(id.to_string(), uuid.to_string());
}
#[test]
fn serde_roundtrip() {
let id = SystemId::new();
let json = serde_json::to_string(&id).unwrap();
let back: SystemId = serde_json::from_str(&json).unwrap();
assert_eq!(id, back);
}