()
| 766 | |
| 767 | #[tokio::test] |
| 768 | async fn test_watcher_multiple_turns() { |
| 769 | let dir = TempDir::new().unwrap(); |
| 770 | |
| 771 | let mut watcher = FallbackWatcher::new(make_config(&dir)); |
| 772 | |
| 773 | // Turn 1: add a file |
| 774 | watcher.begin_turn("sess-1").await.unwrap(); |
| 775 | fs::write(dir.path().join("turn1.rs"), "turn 1").unwrap(); |
| 776 | let changes = watcher.end_turn().await.unwrap(); |
| 777 | assert_eq!(changes.added, vec![PathBuf::from("turn1.rs")]); |
| 778 | |
| 779 | // Turn 2: add another file |
| 780 | watcher.begin_turn("sess-1").await.unwrap(); |
| 781 | fs::write(dir.path().join("turn2.rs"), "turn 2").unwrap(); |
| 782 | let changes = watcher.end_turn().await.unwrap(); |
| 783 | // Should only see turn2.rs, not turn1.rs (which existed before this turn) |
| 784 | assert_eq!(changes.added, vec![PathBuf::from("turn2.rs")]); |
| 785 | assert!(changes.modified.is_empty()); |
| 786 | |
| 787 | // Turn 3: modify turn1.rs |
| 788 | watcher.begin_turn("sess-1").await.unwrap(); |
| 789 | std::thread::sleep(std::time::Duration::from_millis(50)); |
| 790 | fs::write( |
| 791 | dir.path().join("turn1.rs"), |
| 792 | "turn 1 modified with more content", |
| 793 | ) |
| 794 | .unwrap(); |
| 795 | let changes = watcher.end_turn().await.unwrap(); |
| 796 | assert_eq!(changes.modified, vec![PathBuf::from("turn1.rs")]); |
| 797 | assert!(changes.added.is_empty()); |
| 798 | } |
| 799 | |
| 800 | #[tokio::test] |
| 801 | async fn test_watcher_begin_turn_overwrites_previous() { |
nothing calls this directly
no test coverage detected