MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_apply_delete

Function test_apply_delete

atomic-core/src/crdt/apply/leaf.rs:748–777  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

746
747 #[test]
748 fn test_apply_delete() {
749 let mut txn = MockTxn::new();
750 let mut context = ApplyContext::new(ApplyOptions::default());
751 let branch_id = create_test_branch(&mut txn, 1, 0);
752 let leaf_id = LeafId::new(NodeId::new(1), 0);
753
754 // Create first
755 let insert_op = LeafOp::Insert {
756 after: None,
757 kind: TokenKind::Word,
758 content: b"hello".to_vec(),
759 };
760 apply_leaf_op(
761 &mut txn,
762 &mut context,
763 branch_id,
764 leaf_id,
765 &insert_op,
766 b"hello",
767 )
768 .unwrap();
769
770 // Delete
771 let delete_op = LeafOp::Delete { leaf: leaf_id };
772 apply_leaf_op(&mut txn, &mut context, branch_id, leaf_id, &delete_op, &[]).unwrap();
773
774 let leaf = txn.get_leaf(leaf_id).unwrap().unwrap();
775 assert!(leaf.state().is_deleted());
776 assert_eq!(context.stats().leaves_deleted(), 1);
777 }
778
779 #[test]
780 fn test_apply_delete_not_found() {

Callers

nothing calls this directly

Calls 4

create_test_branchFunction · 0.85
apply_leaf_opFunction · 0.70
unwrapMethod · 0.45
get_leafMethod · 0.45

Tested by

no test coverage detected