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

Function test_apply_replace_deleted

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

Source from the content-addressed store, hash-verified

887
888 #[test]
889 fn test_apply_replace_deleted() {
890 let mut txn = MockTxn::new();
891 let mut context = ApplyContext::new(ApplyOptions::default());
892 let branch_id = create_test_branch(&mut txn, 1, 0);
893 let leaf_id = LeafId::new(NodeId::new(1), 0);
894
895 // Create and delete
896 let insert_op = LeafOp::Insert {
897 after: None,
898 kind: TokenKind::Word,
899 content: b"hello".to_vec(),
900 };
901 apply_leaf_op(
902 &mut txn,
903 &mut context,
904 branch_id,
905 leaf_id,
906 &insert_op,
907 b"hello",
908 )
909 .unwrap();
910
911 let delete_op = LeafOp::Delete { leaf: leaf_id };
912 apply_leaf_op(&mut txn, &mut context, branch_id, leaf_id, &delete_op, &[]).unwrap();
913
914 // Try to replace
915 let replace_op = LeafOp::Replace {
916 leaf: leaf_id,
917 new_content: b"world".to_vec(),
918 };
919 let result = apply_leaf_op(
920 &mut txn,
921 &mut context,
922 branch_id,
923 leaf_id,
924 &replace_op,
925 b"world",
926 );
927
928 assert!(result.is_err());
929 assert!(result.unwrap_err().is_invalid_state());
930 }
931
932 // Restore Tests
933

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