Bläddra i källkod

test_delete_force: avoid sporadic test setup issues (#5203)

the old test stumbled over files with an empty chunks list,
so I guess just having some empty file in src/borg could make
that test fail.

fixed this by deleting a chunk of some specific file (we use
this file / this construction at misc. other places in the
archiver tests).
TW 5 år sedan
förälder
incheckning
fcf08106ee
1 ändrade filer med 5 tillägg och 4 borttagningar
  1. 5 4
      src/borg/testsuite/archiver.py

+ 5 - 4
src/borg/testsuite/archiver.py

@@ -1496,11 +1496,12 @@ class ArchiverTestCase(ArchiverTestCaseBase):
             manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
             manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
             archive = Archive(repository, key, manifest, 'test')
             archive = Archive(repository, key, manifest, 'test')
             for item in archive.iter_items():
             for item in archive.iter_items():
-                if 'chunks' in item:
-                    first_chunk_id = item.chunks[0].id
-                    repository.delete(first_chunk_id)
-                    repository.commit()
+                if item.path.endswith('testsuite/archiver.py'):
+                    repository.delete(item.chunks[-1].id)
                     break
                     break
+            else:
+                assert False  # missed the file
+            repository.commit()
         output = self.cmd('delete', '--force', self.repository_location + '::test')
         output = self.cmd('delete', '--force', self.repository_location + '::test')
         self.assert_in('deleted archive was corrupted', output)
         self.assert_in('deleted archive was corrupted', output)
         self.cmd('check', '--repair', self.repository_location)
         self.cmd('check', '--repair', self.repository_location)