refactor: restructure domain crate by bounded context

This commit is contained in:
2026-05-31 04:44:48 +02:00
parent 2b62d1ec81
commit de93373b43
136 changed files with 2111 additions and 2096 deletions

View File

@@ -0,0 +1,45 @@
use domain::value_objects::{MetadataValue, StructuredData};
#[test]
fn insert_and_get() {
let mut sd = StructuredData::new();
sd.insert("key", MetadataValue::String("value".into()));
assert_eq!(sd.get_string("key"), Some("value"));
assert_eq!(sd.len(), 1);
assert!(!sd.is_empty());
}
#[test]
fn merge_from_overwrites() {
let mut a = StructuredData::new();
a.insert("k", MetadataValue::Integer(1));
let mut b = StructuredData::new();
b.insert("k", MetadataValue::Integer(2));
a.merge_from(b);
assert!(matches!(a.get("k"), Some(MetadataValue::Integer(2))));
}
#[test]
fn serde_roundtrip() {
let mut sd = StructuredData::new();
sd.insert("s", MetadataValue::String("hello".into()));
sd.insert("i", MetadataValue::Integer(42));
sd.insert("f", MetadataValue::Float(3.14));
sd.insert("b", MetadataValue::Boolean(true));
sd.insert("n", MetadataValue::Null);
let json = serde_json::to_string(&sd).unwrap();
let back: StructuredData = serde_json::from_str(&json).unwrap();
assert_eq!(sd, back);
}
#[test]
fn remove_works() {
let mut sd = StructuredData::new();
sd.insert("k", MetadataValue::Integer(1));
let removed = sd.remove("k");
assert!(matches!(removed, Some(MetadataValue::Integer(1))));
assert!(sd.is_empty());
}