Test symlinks in external files

This commit is contained in:
Mikhail Gordeev 2024-03-24 21:15:42 +03:00
parent de38e4eadc
commit 6dade88d04

View File

@ -49,7 +49,9 @@ class TestIntegrationImages(TestCase):
cls.work_dir = Path('/tmp/cloud-build') cls.work_dir = Path('/tmp/cloud-build')
shutil.rmtree(cls.work_dir, ignore_errors=True) shutil.rmtree(cls.work_dir, ignore_errors=True)
os.makedirs(cls.work_dir / 'external_files/p9/x86_64', exist_ok=True) os.makedirs(cls.work_dir / 'external_files/p9/x86_64', exist_ok=True)
(cls.work_dir / 'external_files/p9/x86_64/README').write_text('README') readme = cls.work_dir / 'external_files/p9/x86_64/README'
readme.write_text('README')
os.symlink(readme, readme.with_suffix(".txt"))
config = cls.work_dir / 'config.yaml' config = cls.work_dir / 'config.yaml'
branch = cls.branch branch = cls.branch
arch = cls.arch arch = cls.arch
@ -200,6 +202,10 @@ class TestIntegrationImages(TestCase):
def test_external_files(self): def test_external_files(self):
self.assertIn('README', self.images('p9', 'x86_64')) self.assertIn('README', self.images('p9', 'x86_64'))
def test_external_symlinks(self):
readme_txt = self.image_path('p9', 'x86_64', 'README.txt')
self.assertTrue(readme_txt.is_symlink())
def test_verification_files(self): def test_verification_files(self):
for images_list in self.images_lists(): for images_list in self.images_lists():
self.assertIn('SHA256SUMS', images_list) self.assertIn('SHA256SUMS', images_list)
@ -211,11 +217,11 @@ class TestIntegrationImages(TestCase):
'SHA256SUMS', 'SHA256SUMS',
).read_text().splitlines()) ).read_text().splitlines())
index = bool(self.branch) * 2 + bool(self.arch) index = bool(self.branch) * 2 + bool(self.arch)
expected_numbers = [58, 19, 24, 8] expected_numbers = [59, 20, 25, 9]
self.assertEqual(number_of_images, expected_numbers[index]) self.assertEqual(number_of_images, expected_numbers[index])
def test_number_of_images(self): def test_number_of_images(self):
number_of_images = sum(len(lst) for lst in self.images_lists()) number_of_images = sum(len(lst) for lst in self.images_lists())
index = bool(self.branch) * 2 + bool(self.arch) index = bool(self.branch) * 2 + bool(self.arch)
expected_numbers = [62, 78, 70, 102] expected_numbers = [63, 79, 71, 103]
self.assertEqual(number_of_images, expected_numbers[index]) self.assertEqual(number_of_images, expected_numbers[index])