Test handling of missing files (file deleted from monitored directory).
(results: StressTestResults)
| 319 | |
| 320 | |
| 321 | def test_missing_files(results: StressTestResults) -> None: |
| 322 | """Test handling of missing files (file deleted from monitored directory).""" |
| 323 | print("\n📋 TEST 6: Missing File Handling") |
| 324 | print("-" * 70) |
| 325 | |
| 326 | with tempfile.TemporaryDirectory() as temp_dir: |
| 327 | temp_path = Path(temp_dir) |
| 328 | test_dir = temp_path / "test_files" |
| 329 | cache_dir = temp_path / ".cache" |
| 330 | |
| 331 | files = create_test_files(test_dir, 5) |
| 332 | root = str(test_dir) |
| 333 | cache = HashFingerprintCache(cache_dir, "missing_test") |
| 334 | |
| 335 | # First check with all files present |
| 336 | cache.check_needs_update(include=_TEST_INCLUDE, root=root) |
| 337 | cache.mark_success() |
| 338 | results.pass_test("Initial cache with all files") |
| 339 | |
| 340 | # Delete a file |
| 341 | files[0].unlink() |
| 342 | |
| 343 | # Check should detect change (file set changed) |
| 344 | needs_update = cache.check_needs_update(include=_TEST_INCLUDE, root=root) |
| 345 | if needs_update: |
| 346 | results.pass_test("Cache detects missing file as change") |
| 347 | else: |
| 348 | results.fail_test("Cache detects missing file", "Got cache hit instead") |
| 349 | |
| 350 | |
| 351 | def test_cache_corruption_recovery(results: StressTestResults) -> None: |
no test coverage detected