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

Function test_apply_insert

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

Source from the content-addressed store, hash-verified

632
633 #[test]
634 fn test_apply_insert() {
635 let mut txn = MockTxn::new();
636 let mut context = ApplyContext::new(ApplyOptions::default());
637 let branch_id = create_test_branch(&mut txn, 1, 0);
638 let leaf_id = LeafId::new(NodeId::new(1), 0);
639
640 let op = LeafOp::Insert {
641 after: None,
642 kind: TokenKind::Word,
643 content: b"hello".to_vec(),
644 };
645
646 apply_leaf_op(&mut txn, &mut context, branch_id, leaf_id, &op, b"hello").unwrap();
647
648 assert!(txn.has_leaf(leaf_id).unwrap());
649 let leaf = txn.get_leaf(leaf_id).unwrap().unwrap();
650 assert_eq!(leaf.branch(), branch_id);
651 assert_eq!(leaf.kind(), TokenKind::Word);
652 assert!(leaf.state().is_alive());
653 assert_eq!(context.stats().leaves_inserted(), 1);
654 }
655
656 #[test]
657 fn test_apply_insert_after() {

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