Server: domain (entities, value objects, ports), protocol (postcard wire types), application (config service, data projection), adapters (config-memory, tcp-server), bootstrap (composition root with fake data). Client: client-domain (layout engine, render tree, HAL ports), client-application (message handling, repaint commands), adapters (tcp-client, display-terminal), client-desktop (end-to-end working). ESP32: client-esp32 firmware with ILI9341 display over SPI, WiFi networking. Display test verified on hardware — landscape orientation, text rendering works. 60 workspace tests, all passing.
34 lines
856 B
Rust
34 lines
856 B
Rust
use std::collections::BTreeMap;
|
|
use domain::{KeyMapping, Value};
|
|
|
|
#[test]
|
|
fn extracts_value_at_path_and_renames_key() {
|
|
let mapping = KeyMapping {
|
|
source_path: "$.main.temp".into(),
|
|
target_key: "temperature".into(),
|
|
};
|
|
|
|
let raw = Value::Object(BTreeMap::from([
|
|
("main".into(), Value::Object(BTreeMap::from([
|
|
("temp".into(), Value::Number(5.4)),
|
|
]))),
|
|
]));
|
|
|
|
let result = mapping.extract(&raw);
|
|
assert_eq!(result, Some(("temperature".into(), Value::Number(5.4))));
|
|
}
|
|
|
|
#[test]
|
|
fn returns_none_when_path_does_not_match() {
|
|
let mapping = KeyMapping {
|
|
source_path: "$.missing.path".into(),
|
|
target_key: "value".into(),
|
|
};
|
|
|
|
let raw = Value::Object(BTreeMap::from([
|
|
("other".into(), Value::Number(1.0)),
|
|
]));
|
|
|
|
assert_eq!(mapping.extract(&raw), None);
|
|
}
|