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

Function test_apply_restore

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

Source from the content-addressed store, hash-verified

933
934 #[test]
935 fn test_apply_restore() {
936 let mut txn = MockTxn::new();
937 let mut context = ApplyContext::new(ApplyOptions::default());
938 let branch_id = create_test_branch(&mut txn, 1, 0);
939 let leaf_id = LeafId::new(NodeId::new(1), 0);
940
941 // Create and delete
942 let insert_op = LeafOp::Insert {
943 after: None,
944 kind: TokenKind::Word,
945 content: b"hello".to_vec(),
946 };
947 apply_leaf_op(
948 &mut txn,
949 &mut context,
950 branch_id,
951 leaf_id,
952 &insert_op,
953 b"hello",
954 )
955 .unwrap();
956
957 let delete_op = LeafOp::Delete { leaf: leaf_id };
958 apply_leaf_op(&mut txn, &mut context, branch_id, leaf_id, &delete_op, &[]).unwrap();
959
960 // Restore
961 let restore_op = LeafOp::Restore { leaf: leaf_id };
962 apply_leaf_op(&mut txn, &mut context, branch_id, leaf_id, &restore_op, &[]).unwrap();
963
964 let leaf = txn.get_leaf(leaf_id).unwrap().unwrap();
965 assert!(leaf.state().is_alive());
966 assert_eq!(context.stats().leaves_restored(), 1);
967 }
968
969 #[test]
970 fn test_apply_restore_not_deleted() {

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