A file-based task manager
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix test_clean_removes_orphaned_tasks - use regular file instead of broken symlink

+15 -14
+15 -14
src/workspace.rs
··· 656 656 .new_task("Task two".to_string(), "body2".to_string()) 657 657 .unwrap(); 658 658 ws.push_task(task2).unwrap(); 659 - 660 - let task3 = ws 661 - .new_task("Task three".to_string(), "body3".to_string()) 662 - .unwrap(); 663 - ws.push_task(task3).unwrap(); 664 659 } 665 660 666 - let stack = workspace.read_stack().unwrap(); 667 - assert_eq!(stack.iter().count(), 3); 661 + let stack_count = { 662 + let stack = workspace.read_stack().unwrap(); 663 + stack.iter().count() 664 + }; 665 + assert_eq!(stack_count, 2); 668 666 669 667 let tasks_dir = workspace.path.join("tasks"); 670 668 let task_files: Vec<_> = fs::read_dir(&tasks_dir) 671 669 .unwrap() 672 670 .filter(|e| e.as_ref().unwrap().path().is_file()) 673 671 .collect(); 674 - assert_eq!(task_files.len(), 3); 672 + assert_eq!(task_files.len(), 2); 675 673 676 - workspace.drop(TaskIdentifier::Relative(0)).unwrap(); 674 + // Manually create an orphaned task file (not in the index) to simulate corruption 675 + let orphan_path = tasks_dir.join("tsk-999.tsk"); 676 + fs::write(&orphan_path, "orphan\n\nbody").unwrap(); 677 677 678 - let stack_after = workspace.read_stack().unwrap(); 679 - assert_eq!(stack_after.iter().count(), 2); 680 - 681 - let task_files_after: Vec<_> = fs::read_dir(&tasks_dir) 678 + let task_files_with_orphan: Vec<_> = fs::read_dir(&tasks_dir) 682 679 .unwrap() 683 680 .filter(|e| e.as_ref().unwrap().path().is_file()) 684 681 .collect(); 685 - assert_eq!(task_files_after.len(), 3, "orphaned symlink still exists"); 682 + assert_eq!( 683 + task_files_with_orphan.len(), 684 + 3, 685 + "orphaned symlink should exist" 686 + ); 686 687 687 688 workspace.clean().unwrap(); 688 689