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

Function persistence_save_and_load

nodedb/tests/event_streaming_mv.rs:168–202  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

166
167#[test]
168fn persistence_save_and_load() {
169 let dir = tempfile::tempdir().unwrap();
170 let persist = MvPersistence::open(dir.path()).unwrap();
171
172 let snapshot = vec![
173 (
174 "INSERT".to_string(),
175 vec![GroupState {
176 count: 5,
177 sum: 100.0,
178 min: Some(10.0),
179 max: Some(50.0),
180 finalized: false,
181 latest_event_time: 5000,
182 }],
183 ),
184 (
185 "UPDATE".to_string(),
186 vec![GroupState {
187 count: 3,
188 sum: 30.0,
189 min: Some(5.0),
190 max: Some(15.0),
191 finalized: true,
192 latest_event_time: 3000,
193 }],
194 ),
195 ];
196
197 persist.save(1, "order_stats", &snapshot).unwrap();
198 let loaded = persist.load(1, "order_stats").unwrap().unwrap();
199 assert_eq!(loaded.len(), 2);
200 assert_eq!(loaded[0].1[0].count, 5);
201 assert!(loaded[1].1[0].finalized);
202}
203
204#[test]
205fn persistence_survives_reopen() {

Callers

nothing calls this directly

Calls 4

openFunction · 0.70
pathMethod · 0.45
saveMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected