MCPcopy
hub / github.com/borgbackup/borg / test_delete_chunkindex_cache_missing

Function test_delete_chunkindex_cache_missing

src/borg/testsuite/cache_test.py:58–75  ·  view source on GitHub ↗

delete_chunkindex_cache handles StoreObjectNotFound when cache entries do not exist.

(tmp_path)

Source from the content-addressed store, hash-verified

56
57
58def 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
78def test_read_chunkindex_from_repo_cache_missing(tmp_path):

Callers

nothing calls this directly

Calls 3

RepositoryClass · 0.85
delete_chunkindex_cacheFunction · 0.85
store_storeMethod · 0.45

Tested by

no test coverage detected