diff --git a/tests/packages_all.yaml b/tests/packages_all.yaml new file mode 100644 index 0000000..bfbcabd --- /dev/null +++ b/tests/packages_all.yaml @@ -0,0 +1,22 @@ +--- +remote: '/var/empty' +key: 0x00000000 + +images: + rootfs-minimal: + target: ve/docker + kinds: + - tar.xz + packages: + - gosu + +branches: + Sisyphus: + arches: + x86_64: + +packages: + vim-console: + images: + - rootfs-minimal +... diff --git a/tests/packages_external.yaml b/tests/packages_external.yaml new file mode 100644 index 0000000..a57fb06 --- /dev/null +++ b/tests/packages_external.yaml @@ -0,0 +1,23 @@ +--- +remote: '/var/empty' +key: 0x00000000 + +images: + rootfs-minimal: + target: ve/docker + kinds: + - tar.xz + +branches: + Sisyphus: + arches: + x86_64: + +packages: + vim-console: + images: + - rootfs-minimal + gosu: + images: + - rootfs-minimal +... diff --git a/tests/packages_image.yaml b/tests/packages_image.yaml new file mode 100644 index 0000000..c4b094a --- /dev/null +++ b/tests/packages_image.yaml @@ -0,0 +1,18 @@ +--- +remote: '/var/empty' +key: 0x00000000 + +images: + rootfs-minimal: + target: ve/docker + kinds: + - tar.xz + packages: + - gosu + - vim-console + +branches: + Sisyphus: + arches: + x86_64: +... diff --git a/tests/test_packages.py b/tests/test_packages.py new file mode 100644 index 0000000..e93ab59 --- /dev/null +++ b/tests/test_packages.py @@ -0,0 +1,63 @@ +from unittest import TestCase +from unittest import mock + +import shutil +import tempfile + +from cloud_build import CB +from tests.call import Call + + +class TestPackages(TestCase): + def setUp(self): + self.data_dir = tempfile.mkdtemp(prefix='cloud_build') + self.conf_mk = 'mkimage-profiles/conf.d/cloud-build.mk' + self.package_lines = [ + '\t@$(call add,BASE_PACKAGES,vim-console)', + '\t@$(call add,BASE_PACKAGES,gosu)' + ] + + def tearDown(self): + shutil.rmtree(self.data_dir) + + def test_packages_all(self): + with mock.patch('subprocess.call', Call()): + cb = CB( + data_dir=self.data_dir, + config='tests/packages_all.yaml' + ) + cb.ensure_mkimage_profiles() + + conf = cb.work_dir / self.conf_mk + lines = conf.read_text().splitlines() + + for package_line in self.package_lines: + self.assertIn(package_line, lines) + + def test_packages_external(self): + with mock.patch('subprocess.call', Call()): + cb = CB( + data_dir=self.data_dir, + config='tests/packages_external.yaml' + ) + cb.ensure_mkimage_profiles() + + conf = cb.work_dir / self.conf_mk + lines = conf.read_text().splitlines() + + for package_line in self.package_lines: + self.assertIn(package_line, lines) + + def test_packages_images(self): + with mock.patch('subprocess.call', Call()): + cb = CB( + data_dir=self.data_dir, + config='tests/packages_image.yaml' + ) + cb.ensure_mkimage_profiles() + + conf = cb.work_dir / self.conf_mk + lines = conf.read_text().splitlines() + + for package_line in self.package_lines: + self.assertIn(package_line, lines)