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

Function test_validate_leaf_state

atomic-core/src/crdt/apply/leaf.rs:1017–1046  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1015
1016 #[test]
1017 fn test_validate_leaf_state() {
1018 let mut txn = MockTxn::new();
1019 let mut context = ApplyContext::new(ApplyOptions::default());
1020 let branch_id = create_test_branch(&mut txn, 1, 0);
1021 let leaf_id = LeafId::new(NodeId::new(1), 0);
1022
1023 // Create a leaf
1024 let insert_op = LeafOp::Insert {
1025 after: None,
1026 kind: TokenKind::Word,
1027 content: b"hello".to_vec(),
1028 };
1029 apply_leaf_op(
1030 &mut txn,
1031 &mut context,
1032 branch_id,
1033 leaf_id,
1034 &insert_op,
1035 b"hello",
1036 )
1037 .unwrap();
1038
1039 // Validate alive state
1040 let leaf = validate_leaf_state(&txn, leaf_id, Some(LeafState::Alive)).unwrap();
1041 assert!(leaf.state().is_alive());
1042
1043 // Should fail for deleted state
1044 let result = validate_leaf_state(&txn, leaf_id, Some(LeafState::Deleted));
1045 assert!(result.is_err());
1046 }
1047
1048 #[test]
1049 fn test_validate_leaf_parent() {

Callers

nothing calls this directly

Calls 4

create_test_branchFunction · 0.85
validate_leaf_stateFunction · 0.85
apply_leaf_opFunction · 0.70
unwrapMethod · 0.45

Tested by

no test coverage detected