mirror of https://github.com/borgbackup/borg.git
fix check_cache and test_check_cache
NewCache and AdHocCache do not have a persistent chunks index, so both check_cache and test_check_cache are pointless.
This commit is contained in:
parent
ab6049e269
commit
e3a0c4f375
|
@ -18,7 +18,7 @@ import pytest
|
|||
from ... import xattr, platform
|
||||
from ...archive import Archive
|
||||
from ...archiver import Archiver, PURE_PYTHON_MSGPACK_WARNING
|
||||
from ...cache import Cache
|
||||
from ...cache import Cache, LocalCache
|
||||
from ...constants import * # NOQA
|
||||
from ...helpers import Location, umount
|
||||
from ...helpers import EXIT_SUCCESS
|
||||
|
@ -356,9 +356,15 @@ def check_cache(archiver):
|
|||
manifest = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
|
||||
with Cache(repository, manifest, sync=False) as cache:
|
||||
original_chunks = cache.chunks
|
||||
# the LocalCache implementation has an on-disk chunks cache,
|
||||
# but NewCache and AdHocCache don't have persistent chunks cache.
|
||||
persistent = isinstance(cache, LocalCache)
|
||||
Cache.destroy(repository)
|
||||
with Cache(repository, manifest) as cache:
|
||||
correct_chunks = cache.chunks
|
||||
if not persistent:
|
||||
# there is no point in doing the checks
|
||||
return
|
||||
assert original_chunks is not correct_chunks
|
||||
seen = set()
|
||||
for id, (refcount, size) in correct_chunks.iteritems():
|
||||
|
|
|
@ -317,6 +317,9 @@ def test_check_cache(archivers, request):
|
|||
cache.begin_txn()
|
||||
cache.chunks.incref(list(cache.chunks.iteritems())[0][0])
|
||||
cache.commit()
|
||||
persistent = isinstance(cache, LocalCache)
|
||||
if not persistent:
|
||||
pytest.skip("check_cache is pointless if we do not have a persistent chunks cache")
|
||||
with pytest.raises(AssertionError):
|
||||
check_cache(archiver)
|
||||
|
||||
|
|
Loading…
Reference in New Issue