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

Function test_apply_move_path_collision

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

Source from the content-addressed store, hash-verified

735
736 #[test]
737 fn test_apply_move_path_collision() {
738 let mut txn = MockTxn::new();
739 let mut context = ApplyContext::new(ApplyOptions::default());
740
741 let trunk_id1 = TrunkId::new(NodeId::new(1), 0);
742 let trunk_id2 = TrunkId::new(NodeId::new(2), 0);
743
744 // Create two files
745 let create1 = TrunkOp::Create {
746 path: "file1.rs".to_string(),
747 encoding: None,
748 };
749 let create2 = TrunkOp::Create {
750 path: "file2.rs".to_string(),
751 encoding: None,
752 };
753 apply_trunk_op(&mut txn, &mut context, trunk_id1, &create1).unwrap();
754 apply_trunk_op(&mut txn, &mut context, trunk_id2, &create2).unwrap();
755
756 // Try to move file1 to file2's path
757 let move_op = TrunkOp::Move {
758 trunk: trunk_id1,
759 new_path: "file2.rs".to_string(),
760 };
761 let result = apply_trunk_op(&mut txn, &mut context, trunk_id1, &move_op);
762
763 assert!(result.is_err());
764 assert!(result.unwrap_err().is_already_exists());
765 }
766
767 #[test]
768 fn test_apply_move_same_path() {

Callers

nothing calls this directly

Calls 2

apply_trunk_opFunction · 0.70
unwrapMethod · 0.45

Tested by

no test coverage detected