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

Function raw_msgpack_roundtrip

nodedb/src/engine/document/store/engine/tests.rs:141–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139
140#[test]
141fn raw_msgpack_roundtrip() {
142 let (sparse, _dir) = make_engine();
143 let doc_engine = DocumentEngine::new(&sparse, 1);
144
145 let doc = serde_json::json!({"key": "value", "num": 42});
146 let rmpv_val = json_to_msgpack(&doc);
147 let mut buf = Vec::new();
148 rmpv::encode::write_value(&mut buf, &rmpv_val).unwrap();
149
150 doc_engine.put_raw("col", "id1", &buf).unwrap();
151
152 let raw = doc_engine.get_raw("col", "id1").unwrap().unwrap();
153 assert_eq!(raw, buf);
154
155 let decoded = doc_engine.get("col", "id1").unwrap().unwrap();
156 assert_eq!(decoded["key"], "value");
157 assert_eq!(decoded["num"], 42);
158}
159
160#[test]
161fn collections_are_isolated() {

Callers

nothing calls this directly

Calls 5

make_engineFunction · 0.70
json_to_msgpackFunction · 0.50
put_rawMethod · 0.45
get_rawMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected