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

Function test_apply_insert_duplicate_id

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

Source from the content-addressed store, hash-verified

685
686 #[test]
687 fn test_apply_insert_duplicate_id() {
688 let mut txn = MockTxn::new();
689 let mut context = ApplyContext::new(ApplyOptions::default());
690 let branch_id = create_test_branch(&mut txn, 1, 0);
691 let leaf_id = LeafId::new(NodeId::new(1), 0);
692
693 let op = LeafOp::Insert {
694 after: None,
695 kind: TokenKind::Word,
696 content: b"hello".to_vec(),
697 };
698
699 apply_leaf_op(&mut txn, &mut context, branch_id, leaf_id, &op, b"hello").unwrap();
700
701 // Try to insert again with same ID
702 let result = apply_leaf_op(&mut txn, &mut context, branch_id, leaf_id, &op, b"hello");
703 assert!(result.is_err());
704 assert!(result.unwrap_err().is_already_exists());
705 }
706
707 #[test]
708 fn test_apply_insert_duplicate_id_lenient() {

Callers

nothing calls this directly

Calls 3

create_test_branchFunction · 0.85
apply_leaf_opFunction · 0.70
unwrapMethod · 0.45

Tested by

no test coverage detected