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

Function test_apply_insert_after

atomic-core/src/crdt/apply/branch.rs:711–736  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

709
710 #[test]
711 fn test_apply_insert_after() {
712 let mut txn = MockTxn::new();
713 let mut context = ApplyContext::new(ApplyOptions::default());
714 let trunk_id = create_test_trunk(&mut txn, 1);
715
716 let branch_id1 = BranchId::new(NodeId::new(1), 0);
717 let branch_id2 = BranchId::new(NodeId::new(1), 1);
718
719 // Insert first branch
720 let op1 = BranchOp::Insert {
721 after: None,
722 content: vec![],
723 };
724 apply_branch_op(&mut txn, &mut context, trunk_id, branch_id1, &op1, &[]).unwrap();
725
726 // Insert second branch after first
727 let op2 = BranchOp::Insert {
728 after: Some(branch_id1),
729 content: vec![],
730 };
731 apply_branch_op(&mut txn, &mut context, trunk_id, branch_id2, &op2, &[]).unwrap();
732
733 assert!(txn.has_branch(branch_id1).unwrap());
734 assert!(txn.has_branch(branch_id2).unwrap());
735 assert_eq!(context.stats().branches_inserted(), 2);
736 }
737
738 #[test]
739 fn test_apply_insert_duplicate_id() {

Callers

nothing calls this directly

Calls 3

create_test_trunkFunction · 0.85
apply_branch_opFunction · 0.85
unwrapMethod · 0.45

Tested by

no test coverage detected