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

Function test_validate_path_available

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

Source from the content-addressed store, hash-verified

875
876 #[test]
877 fn test_validate_path_available() {
878 let mut txn = MockTxn::new();
879 let mut context = ApplyContext::new(ApplyOptions::default());
880 let trunk_id = TrunkId::new(NodeId::new(1), 0);
881
882 // Path is available before creating
883 validate_path_available(&txn, "test.rs", None).unwrap();
884
885 // Create a trunk
886 let create_op = TrunkOp::Create {
887 path: "test.rs".to_string(),
888 encoding: None,
889 };
890 apply_trunk_op(&mut txn, &mut context, trunk_id, &create_op).unwrap();
891
892 // Path is now taken
893 let result = validate_path_available(&txn, "test.rs", None);
894 assert!(result.is_err());
895
896 // But available if we exclude the owner
897 validate_path_available(&txn, "test.rs", Some(trunk_id)).unwrap();
898 }
899}

Callers

nothing calls this directly

Calls 3

validate_path_availableFunction · 0.85
apply_trunk_opFunction · 0.70
unwrapMethod · 0.45

Tested by

no test coverage detected