MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / decode_grouped_response

Function decode_grouped_response

nodedb/src/event/alert/executor.rs:337–357  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

335
336 #[test]
337 fn decode_grouped_response() {
338 // Build a response: [{device_id: "pump-1", avg_temperature: 95.5}]
339 let row = rmpv::Value::Map(vec![
340 (
341 rmpv::Value::String("device_id".into()),
342 rmpv::Value::String("pump-1".into()),
343 ),
344 (
345 rmpv::Value::String("avg_temperature".into()),
346 rmpv::Value::F64(95.5),
347 ),
348 ]);
349 let array = rmpv::Value::Array(vec![row]);
350 let mut buf = Vec::new();
351 rmpv::encode::write_value(&mut buf, &array).unwrap();
352
353 let results = decode_aggregate_response(&buf, &["device_id".to_string()], "avg").unwrap();
354 assert_eq!(results.len(), 1);
355 assert_eq!(results[0].0, "pump-1");
356 assert!((results[0].1 - 95.5).abs() < 1e-12);
357 }
358
359 #[test]
360 fn decode_no_group_response() {

Callers

nothing calls this directly

Calls 2

to_stringMethod · 0.80

Tested by

no test coverage detected