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

Function test_apply_move

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

Source from the content-addressed store, hash-verified

681
682 #[test]
683 fn test_apply_move() {
684 let mut txn = MockTxn::new();
685 let mut context = ApplyContext::new(ApplyOptions::default());
686 let trunk_id = TrunkId::new(NodeId::new(1), 0);
687
688 // Create
689 let create_op = TrunkOp::Create {
690 path: "old.rs".to_string(),
691 encoding: None,
692 };
693 apply_trunk_op(&mut txn, &mut context, trunk_id, &create_op).unwrap();
694
695 // Move
696 let move_op = TrunkOp::Move {
697 trunk: trunk_id,
698 new_path: "new.rs".to_string(),
699 };
700 apply_trunk_op(&mut txn, &mut context, trunk_id, &move_op).unwrap();
701
702 let trunk = txn.get_trunk(trunk_id).unwrap().unwrap();
703 assert_eq!(trunk.path(), "new.rs");
704 assert!(txn.get_trunk_by_path("old.rs").unwrap().is_none());
705 assert_eq!(txn.get_trunk_by_path("new.rs").unwrap(), Some(trunk_id));
706 assert_eq!(context.stats().trunks_moved(), 1);
707 }
708
709 #[test]
710 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