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

Function test_apply_restore

atomic-core/src/crdt/apply/branch.rs:900–934  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 4

create_test_trunkFunction · 0.85
apply_branch_opFunction · 0.85
unwrapMethod · 0.45
get_branchMethod · 0.45

Tested by

no test coverage detected