- React SPA: dashboard, data sources CRUD, widgets CRUD, layout builder, presets. TanStack Router + Query, shadcn/ui, Vite proxy to :3000 - wire media + rss adapters into polling loop, remove xtb source type - media adapter: read username/password from headers, proper subsonic auth - event handler: subscribe to LayoutChanged, push screen update to clients - fix clippy warnings across workspace (Default impls, collapsible ifs, redundant closures, is_none_or, unused imports)
31 lines
826 B
Rust
31 lines
826 B
Rust
use domain::{KeyMapping, Value};
|
|
use std::collections::BTreeMap;
|
|
|
|
#[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);
|
|
}
|