mirror of
https://github.com/borgbackup/borg.git
synced 2026-07-15 13:06:55 -04:00
tests: drop the delete_chunk wrapper, call Repository.delete directly
Inline repository.delete at the check/extract/mount call sites. Drop the borgstore HEAD note from compact_pack now that it is fixed upstream.
This commit is contained in:
parent
e74d7ef9a0
commit
106dfbadae
5 changed files with 8 additions and 16 deletions
|
|
@ -856,9 +856,8 @@ class Repository:
|
|||
located.sort()
|
||||
|
||||
# keep + drop tile the pack contiguously from offset 0; collect the objects to keep in the same
|
||||
# pass. we do not cross-check against the pack's on-disk size: that needs a store.info() HEAD,
|
||||
# which the stdio rest backend mishandles (it blocks reading a body the HEAD response never
|
||||
# carries), and the caller already guarantees the two sets are the pack's complete object set.
|
||||
# pass. we do not cross-check against the pack's on-disk size: the caller already guarantees the
|
||||
# two sets are the pack's complete object set.
|
||||
kept = [] # (obj_offset, obj_id, obj_size), offset-ordered
|
||||
covered = 0
|
||||
for offset, obj_id, size, keep in located:
|
||||
|
|
|
|||
|
|
@ -179,11 +179,6 @@ def open_archive(repo_path, name):
|
|||
return archive, repository
|
||||
|
||||
|
||||
def delete_chunk(repository, id):
|
||||
"""Remove a single chunk from the repo, leaving the rest of its pack intact (test damage helper)."""
|
||||
repository.delete(id)
|
||||
|
||||
|
||||
def open_repository(archiver):
|
||||
if archiver.get_kind() == "remote":
|
||||
return Repository(Location(archiver.repository_location), exclusive=True)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from ...helpers import bin_to_hex, msgpack
|
|||
from ...manifest import Manifest
|
||||
from ...repository import Repository
|
||||
from ..repository_test import fchunk
|
||||
from . import cmd, src_file, create_src_archive, open_archive, delete_chunk, generate_archiver_tests, RK_ENCRYPTION
|
||||
from . import cmd, src_file, create_src_archive, open_archive, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ def test_missing_file_chunk(archivers, request):
|
|||
if item.path.endswith(src_file):
|
||||
valid_chunks = item.chunks
|
||||
killed_chunk = valid_chunks[-1]
|
||||
delete_chunk(repository, killed_chunk.id)
|
||||
repository.delete(killed_chunk.id)
|
||||
break
|
||||
else:
|
||||
pytest.fail("should not happen") # convert 'fail'
|
||||
|
|
@ -198,7 +198,7 @@ def test_missing_archive_item_chunk(archivers, request):
|
|||
check_cmd_setup(archiver)
|
||||
archive, repository = open_archive(archiver.repository_path, "archive1")
|
||||
with repository:
|
||||
delete_chunk(repository, archive.metadata.items[0])
|
||||
repository.delete(archive.metadata.items[0])
|
||||
cmd(archiver, "check", exit_code=1)
|
||||
cmd(archiver, "check", "--repair", exit_code=0)
|
||||
cmd(archiver, "check", exit_code=0)
|
||||
|
|
@ -209,7 +209,7 @@ def test_missing_archive_metadata(archivers, request):
|
|||
check_cmd_setup(archiver)
|
||||
archive, repository = open_archive(archiver.repository_path, "archive1")
|
||||
with repository:
|
||||
delete_chunk(repository, archive.id)
|
||||
repository.delete(archive.id)
|
||||
cmd(archiver, "check", exit_code=1)
|
||||
cmd(archiver, "check", "--repair", exit_code=0)
|
||||
cmd(archiver, "check", exit_code=0)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ from . import (
|
|||
generate_archiver_tests,
|
||||
create_src_archive,
|
||||
open_archive,
|
||||
delete_chunk,
|
||||
src_file,
|
||||
)
|
||||
|
||||
|
|
@ -801,7 +800,7 @@ def test_extract_file_with_missing_chunk(archivers, request):
|
|||
for item in archive.iter_items():
|
||||
if item.path.endswith(src_file):
|
||||
chunk = item.chunks[-1]
|
||||
delete_chunk(repository, chunk.id)
|
||||
repository.delete(chunk.id)
|
||||
break
|
||||
else:
|
||||
assert False # missed the file
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from .. import changedir, filter_xattrs, same_ts_ns
|
|||
from .. import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported
|
||||
from ..platform.platform_test import fakeroot_detected
|
||||
from . import RK_ENCRYPTION, cmd, assert_dirs_equal, create_regular_file, create_src_archive, open_archive, src_file
|
||||
from . import delete_chunk
|
||||
from . import requires_hardlinks, _extract_hardlinks_setup, fuse_mount, create_test_files, generate_archiver_tests
|
||||
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
|
@ -235,7 +234,7 @@ def test_fuse_allow_damaged_files(archivers, request):
|
|||
with repository:
|
||||
for item in archive.iter_items():
|
||||
if item.path.endswith(src_file):
|
||||
delete_chunk(repository, item.chunks[-1].id)
|
||||
repository.delete(item.chunks[-1].id)
|
||||
path = item.path # store full path for later
|
||||
break
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue