delete_chunkindex_cache handles StoreObjectNotFound when cache entries do not exist.
(tmp_path)
| 56 | |
| 57 | |
| 58 | def test_delete_chunkindex_cache_missing(tmp_path): |
| 59 | """delete_chunkindex_cache handles StoreObjectNotFound when cache entries do not exist.""" |
| 60 | from borgstore.store import ObjectNotFound as StoreObjectNotFound |
| 61 | |
| 62 | repository_location = os.fspath(tmp_path / "repository") |
| 63 | with Repository(repository_location, exclusive=True, create=True) as repository: |
| 64 | # Create a cache entry so list_chunkindex_hashes finds it. |
| 65 | repository.store_store(f"cache/chunks.{'a' * 64}", b"data") |
| 66 | # Patch store_delete to raise StoreObjectNotFound (simulates a race or already-deleted entry). |
| 67 | original_store_delete = repository.store_delete |
| 68 | |
| 69 | def failing_store_delete(name): |
| 70 | raise StoreObjectNotFound(name) |
| 71 | |
| 72 | repository.store_delete = failing_store_delete |
| 73 | # Should not raise — the except StoreObjectNotFound catches it. |
| 74 | delete_chunkindex_cache(repository) |
| 75 | repository.store_delete = original_store_delete |
| 76 | |
| 77 | |
| 78 | def test_read_chunkindex_from_repo_cache_missing(tmp_path): |
nothing calls this directly
no test coverage detected