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

Function roundtrip_simple

nodedb-query/src/msgpack_scan/sidecar.rs:382–397  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

380
381 #[test]
382 fn roundtrip_simple() {
383 let raw = encode(&json!({"name": "alice", "age": 30, "score": 99.5}));
384 let indexed = build_sidecar(&raw).expect("build_sidecar");
385
386 assert!(has_sidecar(&indexed));
387 assert_eq!(msgpack_bytes(&indexed), raw.as_slice());
388
389 let (s, _) = sidecar_lookup(&indexed, "name").expect("name");
390 assert_eq!(read_str(&indexed, s), Some("alice"));
391
392 let (s, _) = sidecar_lookup(&indexed, "age").expect("age");
393 assert_eq!(read_i64(&indexed, s), Some(30));
394
395 let (s, _) = sidecar_lookup(&indexed, "score").expect("score");
396 assert_eq!(read_f64(&indexed, s), Some(99.5));
397 }
398
399 #[test]
400 fn missing_field_returns_none() {

Callers

nothing calls this directly

Calls 4

sidecar_lookupFunction · 0.85
encodeFunction · 0.70
build_sidecarFunction · 0.70
expectMethod · 0.45

Tested by

no test coverage detected