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

Function update_replaces_entry

nodedb/src/engine/sparse/gsi.rs:398–422  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

396
397 #[test]
398 fn update_replaces_entry() {
399 let (store, _dir) = open_store();
400 store
401 .create_index(1, "users", "email_idx", "email", vec![])
402 .unwrap();
403 let indexes = store.list_indexes(1, "users").unwrap();
404
405 let doc1 = serde_json::json!({"email": "old@example.com"});
406 store
407 .index_document(1, "users", "u1", 0, &doc1, &indexes)
408 .unwrap();
409
410 let doc2 = serde_json::json!({"email": "new@example.com"});
411 store
412 .index_document(1, "users", "u1", 0, &doc2, &indexes)
413 .unwrap();
414
415 // Old value still has the stale entry because we only deduplicate
416 // within the same key. A separate cleanup handles stale entries.
417 let _old = store.lookup("email_idx", "old@example.com").unwrap();
418 // The new value should have the entry.
419 let new = store.lookup("email_idx", "new@example.com").unwrap();
420 assert_eq!(new.len(), 1);
421 assert_eq!(new[0].document_id, "u1");
422 }
423}

Callers

nothing calls this directly

Calls 5

create_indexMethod · 0.80
list_indexesMethod · 0.80
open_storeFunction · 0.70
index_documentMethod · 0.45
lookupMethod · 0.45

Tested by

no test coverage detected