mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
tests: use a smaller dir for src_dir, fixes #7518
also: introduce src_file, which is a file in src_dir.
This commit is contained in:
parent
9263705de7
commit
4505c90920
4 changed files with 15 additions and 17 deletions
|
@ -33,7 +33,9 @@
|
|||
RK_ENCRYPTION = "--encryption=repokey-aes-ocb"
|
||||
KF_ENCRYPTION = "--encryption=keyfile-chacha20-poly1305"
|
||||
|
||||
src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
# this points to src/borg/archiver directory (which is small and has only a few files)
|
||||
src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "archiver"))
|
||||
src_file = "archiver/__init__.py" # relative path of one file in src_dir
|
||||
|
||||
requires_hardlinks = pytest.mark.skipif(not are_hardlinks_supported(), reason="hardlinks not supported")
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
from ...manifest import Manifest
|
||||
from ...repository import Repository
|
||||
from . import ArchiverTestCaseBase, RemoteArchiverTestCaseBase, ArchiverTestCaseBinaryBase, RK_ENCRYPTION, BORG_EXES
|
||||
from . import src_file
|
||||
|
||||
|
||||
class ArchiverCheckTestCase(ArchiverTestCaseBase):
|
||||
|
@ -95,7 +96,7 @@ def test_missing_file_chunk(self):
|
|||
archive, repository = self.open_archive("archive1")
|
||||
with repository:
|
||||
for item in archive.iter_items():
|
||||
if item.path.endswith("testsuite/archiver/__init__.py"):
|
||||
if item.path.endswith(src_file):
|
||||
valid_chunks = item.chunks
|
||||
killed_chunk = valid_chunks[-1]
|
||||
repository.delete(killed_chunk.id)
|
||||
|
@ -116,7 +117,7 @@ def test_missing_file_chunk(self):
|
|||
archive, repository = self.open_archive(archive_name)
|
||||
with repository:
|
||||
for item in archive.iter_items():
|
||||
if item.path.endswith("testsuite/archiver/__init__.py"):
|
||||
if item.path.endswith(src_file):
|
||||
self.assert_not_equal(valid_chunks, item.chunks)
|
||||
self.assert_not_in(killed_chunk, item.chunks)
|
||||
break
|
||||
|
@ -128,13 +129,13 @@ def test_missing_file_chunk(self):
|
|||
# check should be able to heal the file now:
|
||||
output = self.cmd(f"--repo={self.repository_location}", "check", "-v", "--repair", exit_code=0)
|
||||
self.assert_in("Healed previously missing file chunk", output)
|
||||
self.assert_in("testsuite/archiver/__init__.py: Completely healed previously damaged file!", output)
|
||||
self.assert_in(f"{src_file}: Completely healed previously damaged file!", output)
|
||||
# check that the file in the old archives has the correct chunks again
|
||||
for archive_name in ("archive1", "archive2"):
|
||||
archive, repository = self.open_archive(archive_name)
|
||||
with repository:
|
||||
for item in archive.iter_items():
|
||||
if item.path.endswith("testsuite/archiver/__init__.py"):
|
||||
if item.path.endswith(src_file):
|
||||
self.assert_equal(valid_chunks, item.chunks)
|
||||
break
|
||||
else:
|
||||
|
@ -251,7 +252,7 @@ def _test_verify_data(self, *init_args):
|
|||
archive, repository = self.open_archive("archive1")
|
||||
with repository:
|
||||
for item in archive.iter_items():
|
||||
if item.path.endswith("testsuite/archiver/__init__.py"):
|
||||
if item.path.endswith(src_file):
|
||||
chunk = item.chunks[-1]
|
||||
data = repository.get(chunk.id)
|
||||
data = data[0:100] + b"x" + data[101:]
|
||||
|
@ -264,7 +265,7 @@ def _test_verify_data(self, *init_args):
|
|||
# repair (heal is tested in another test)
|
||||
output = self.cmd(f"--repo={self.repository_location}", "check", "--repair", "--verify-data", exit_code=0)
|
||||
assert bin_to_hex(chunk.id) + ", integrity error" in output
|
||||
assert "testsuite/archiver/__init__.py: New missing file chunk detected" in output
|
||||
assert f"{src_file}: New missing file chunk detected" in output
|
||||
|
||||
def test_verify_data(self):
|
||||
self._test_verify_data(RK_ENCRYPTION)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
from ...manifest import Manifest
|
||||
from ...repository import Repository
|
||||
from . import ArchiverTestCaseBase, RemoteArchiverTestCaseBase, ArchiverTestCaseBinaryBase, RK_ENCRYPTION, BORG_EXES
|
||||
from . import src_file
|
||||
|
||||
|
||||
class ArchiverTestCase(ArchiverTestCaseBase):
|
||||
|
@ -48,7 +49,7 @@ def test_delete_force(self):
|
|||
manifest = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
|
||||
archive = Archive(manifest, "test")
|
||||
for item in archive.iter_items():
|
||||
if item.path.endswith("testsuite/archiver/__init__.py"):
|
||||
if item.path.endswith(src_file):
|
||||
repository.delete(item.chunks[-1].id)
|
||||
break
|
||||
else:
|
||||
|
|
|
@ -14,14 +14,8 @@
|
|||
from .. import changedir, no_selinux, same_ts_ns
|
||||
from .. import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported
|
||||
from ..platform import fakeroot_detected
|
||||
from . import (
|
||||
ArchiverTestCaseBase,
|
||||
ArchiverTestCaseBinaryBase,
|
||||
RemoteArchiverTestCaseBase,
|
||||
RK_ENCRYPTION,
|
||||
requires_hardlinks,
|
||||
BORG_EXES,
|
||||
)
|
||||
from . import ArchiverTestCaseBase, ArchiverTestCaseBinaryBase, RemoteArchiverTestCaseBase, RK_ENCRYPTION, BORG_EXES
|
||||
from . import src_file, requires_hardlinks
|
||||
|
||||
|
||||
class ArchiverTestCase(ArchiverTestCaseBase):
|
||||
|
@ -205,7 +199,7 @@ def test_fuse_allow_damaged_files(self):
|
|||
archive, repository = self.open_archive("archive")
|
||||
with repository:
|
||||
for item in archive.iter_items():
|
||||
if item.path.endswith("testsuite/archiver/__init__.py"):
|
||||
if item.path.endswith(src_file):
|
||||
repository.delete(item.chunks[-1].id)
|
||||
path = item.path # store full path for later
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue