()
| 898 | |
| 899 | #[test] |
| 900 | fn test_apply_restore() { |
| 901 | let mut txn = MockTxn::new(); |
| 902 | let mut context = ApplyContext::new(ApplyOptions::default()); |
| 903 | let trunk_id = create_test_trunk(&mut txn, 1); |
| 904 | let branch_id = BranchId::new(NodeId::new(1), 0); |
| 905 | |
| 906 | // Create and delete |
| 907 | let insert_op = BranchOp::Insert { |
| 908 | after: None, |
| 909 | content: vec![], |
| 910 | }; |
| 911 | apply_branch_op(&mut txn, &mut context, trunk_id, branch_id, &insert_op, &[]).unwrap(); |
| 912 | |
| 913 | let delete_op = BranchOp::Delete { |
| 914 | branch: branch_id, |
| 915 | content: vec![], |
| 916 | }; |
| 917 | apply_branch_op(&mut txn, &mut context, trunk_id, branch_id, &delete_op, &[]).unwrap(); |
| 918 | |
| 919 | // Restore |
| 920 | let restore_op = BranchOp::Restore { branch: branch_id }; |
| 921 | apply_branch_op( |
| 922 | &mut txn, |
| 923 | &mut context, |
| 924 | trunk_id, |
| 925 | branch_id, |
| 926 | &restore_op, |
| 927 | &[], |
| 928 | ) |
| 929 | .unwrap(); |
| 930 | |
| 931 | let branch = txn.get_branch(branch_id).unwrap().unwrap(); |
| 932 | assert!(branch.state().is_alive()); |
| 933 | assert_eq!(context.stats().branches_restored(), 1); |
| 934 | } |
| 935 | |
| 936 | #[test] |
| 937 | fn test_apply_restore_not_deleted() { |
nothing calls this directly
no test coverage detected