Add tests for size
This commit is contained in:
parent
b4ec5f05b4
commit
7d73dafdcf
16
tests/test_bad_size.yaml
Normal file
16
tests/test_bad_size.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
remote: '/var/empty'
|
||||
key: 0x00000000
|
||||
|
||||
images:
|
||||
rootfs-minimal:
|
||||
target: ve/docker
|
||||
size: M10
|
||||
kinds:
|
||||
- tar.xz
|
||||
|
||||
branches:
|
||||
Sisyphus:
|
||||
arches:
|
||||
x86_64:
|
||||
...
|
@ -119,3 +119,12 @@ class TestErrors(TestCase):
|
||||
regex = 'years.*rebuild_after'
|
||||
self.kwargs.update(config='tests/test_rebuild_after_format.yaml')
|
||||
self.assertRaisesRegex(Error, regex, CB, **self.kwargs)
|
||||
|
||||
def test_bad_size(self):
|
||||
regex = 'Bad size.*'
|
||||
cloud_build = CB(
|
||||
config='tests/test_bad_size.yaml',
|
||||
data_dir=self.kwargs['data_dir'],
|
||||
no_tests=True,
|
||||
)
|
||||
self.assertRaisesRegex(Error, regex, cloud_build.create_images)
|
||||
|
28
tests/test_utils.py
Normal file
28
tests/test_utils.py
Normal file
@ -0,0 +1,28 @@
|
||||
from unittest import TestCase
|
||||
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
from cloud_build import CB
|
||||
|
||||
|
||||
class TestUtils(TestCase):
|
||||
def setUp(self):
|
||||
kwargs = {
|
||||
'data_dir': tempfile.mkdtemp(prefix='cloud_build'),
|
||||
'config': 'tests/minimal_config.yaml',
|
||||
}
|
||||
self.kwargs = kwargs
|
||||
self.cb = CB(**kwargs)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.kwargs['data_dir'])
|
||||
|
||||
def test_conver_size_lower_case(self):
|
||||
self.assertEqual(self.cb.convert_size('200k'), '204800')
|
||||
|
||||
def test_conver_size_upper_case(self):
|
||||
self.assertEqual(self.cb.convert_size('1M'), '1048576')
|
||||
|
||||
def test_conver_size_real(self):
|
||||
self.assertEqual(self.cb.convert_size('0.1G'), '107374182')
|
Loading…
Reference in New Issue
Block a user