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

Function test_apply_move

atomic-core/src/crdt/apply/trunk.rs:690–714  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

688
689 #[test]
690 fn test_apply_move() {
691 let mut txn = MockTxn::new();
692 let mut context = ApplyContext::new(ApplyOptions::default());
693 let trunk_id = TrunkId::new(NodeId::new(1), 0);
694
695 // Create
696 let create_op = TrunkOp::Create {
697 path: "old.rs".to_string(),
698 encoding: None,
699 };
700 apply_trunk_op(&mut txn, &mut context, trunk_id, &create_op).unwrap();
701
702 // Move
703 let move_op = TrunkOp::Move {
704 trunk: trunk_id,
705 new_path: "new.rs".to_string(),
706 };
707 apply_trunk_op(&mut txn, &mut context, trunk_id, &move_op).unwrap();
708
709 let trunk = txn.get_trunk(trunk_id).unwrap().unwrap();
710 assert_eq!(trunk.path(), "new.rs");
711 assert!(txn.get_trunk_by_path("old.rs").unwrap().is_none());
712 assert_eq!(txn.get_trunk_by_path("new.rs").unwrap(), Some(trunk_id));
713 assert_eq!(context.stats().trunks_moved(), 1);
714 }
715
716 #[test]
717 fn test_apply_move_deleted() {

Callers

nothing calls this directly

Calls 3

apply_trunk_opFunction · 0.70
unwrapMethod · 0.45
get_trunkMethod · 0.45

Tested by

no test coverage detected