()
| 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() { |
nothing calls this directly
no test coverage detected