Merge pull request #5479 from milkey-mouse/fix-5438

Fix spurious failure in test_cache_files
This commit is contained in:
TW 2020-11-03 13:57:51 +01:00 committed by GitHub
commit 5334dbc0ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -3686,10 +3686,12 @@ class ArchiverCorruptionTestCase(ArchiverTestCaseBase):
self.cmd('init', '--encryption=repokey', self.repository_location)
self.cache_path = json.loads(self.cmd('info', self.repository_location, '--json'))['cache']['path']
def corrupt(self, file):
def corrupt(self, file, amount=1):
with open(file, 'r+b') as fd:
fd.seek(-1, io.SEEK_END)
fd.write(b'1')
fd.seek(-amount, io.SEEK_END)
corrupted = bytes(255-c for c in fd.read(amount))
fd.seek(-amount, io.SEEK_END)
fd.write(corrupted)
def test_cache_chunks(self):
self.corrupt(os.path.join(self.cache_path, 'chunks'))