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:884–905  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

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