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

Function test_move_tracked_file

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected