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

Function test_move_tracked_file

atomic-repository/src/tracking/tests.rs:555–591  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

553
554#[test]
555fn test_move_tracked_file() {
556 use atomic_core::pristine::Pristine;
557 use tempfile::TempDir;
558
559 let temp_dir = TempDir::new().unwrap();
560 let db_path = temp_dir.path().join("pristine.redb");
561
562 let pristine = Pristine::open(&db_path).unwrap();
563
564 let original_inode;
565
566 // Add a file
567 {
568 let mut txn = pristine.write_txn().unwrap();
569 original_inode = add_to_tree(&mut txn, "old_name.rs", false).unwrap();
570 txn.commit().unwrap();
571 }
572
573 // Move it
574 {
575 let mut txn = pristine.write_txn().unwrap();
576 let moved_inode = move_tracked(&mut txn, "old_name.rs", "new_name.rs").unwrap();
577 assert_eq!(moved_inode, original_inode); // Inode preserved!
578 txn.commit().unwrap();
579 }
580
581 // Verify the move
582 {
583 let txn = pristine.read_txn().unwrap();
584 assert!(!is_tracked(&txn, "old_name.rs").unwrap());
585 assert!(is_tracked(&txn, "new_name.rs").unwrap());
586
587 // Same inode
588 let inode = get_inode(&txn, "new_name.rs").unwrap();
589 assert_eq!(inode, Some(original_inode));
590 }
591}
592
593#[test]
594fn test_list_tracked_files() {

Callers

nothing calls this directly

Calls 9

openFunction · 0.85
add_to_treeFunction · 0.85
move_trackedFunction · 0.85
get_inodeFunction · 0.85
write_txnMethod · 0.80
read_txnMethod · 0.80
unwrapMethod · 0.45
pathMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected