Add tests for packages
This commit is contained in:
parent
c119fb703b
commit
63cc5294e8
22
tests/packages_all.yaml
Normal file
22
tests/packages_all.yaml
Normal file
@ -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
|
||||
...
|
23
tests/packages_external.yaml
Normal file
23
tests/packages_external.yaml
Normal file
@ -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
|
||||
...
|
18
tests/packages_image.yaml
Normal file
18
tests/packages_image.yaml
Normal file
@ -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:
|
||||
...
|
63
tests/test_packages.py
Normal file
63
tests/test_packages.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user