diff options
author | Josh Smith <qinusty@gmail.com> | 2018-09-19 09:32:14 +0100 |
---|---|---|
committer | richardmaw-codethink <richard.maw@codethink.co.uk> | 2018-11-06 13:23:19 +0000 |
commit | d3a07e6b4a4d581755d4bf350562b775cad9f69b (patch) | |
tree | 7188868673d7a801b66cc6b20f625f28110c684a /tests/utils | |
parent | 9a045080ac1e5c3554baccb566d06303ab9b2fbd (diff) | |
download | buildstream-d3a07e6b4a4d581755d4bf350562b775cad9f69b.tar.gz |
Add regression test for _pretty_size
Diffstat (limited to 'tests/utils')
-rw-r--r-- | tests/utils/misc.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/utils/misc.py b/tests/utils/misc.py new file mode 100644 index 000000000..ae584e4d5 --- /dev/null +++ b/tests/utils/misc.py @@ -0,0 +1,30 @@ +from buildstream import _yaml +from ..testutils import mock_os +from ..testutils.runcli import cli + +import os +import pytest + + +KiB = 1024 +MiB = (KiB * 1024) +GiB = (MiB * 1024) +TiB = (GiB * 1024) + + +def test_parse_size_over_1024T(cli, tmpdir): + BLOCK_SIZE = 4096 + cli.configure({ + 'cache': { + 'quota': 2048 * TiB + } + }) + project = tmpdir.join("main") + os.makedirs(str(project)) + _yaml.dump({'name': 'main'}, str(project.join("project.conf"))) + + bavail = (1025 * TiB) / BLOCK_SIZE + patched_statvfs = mock_os.mock_statvfs(f_bavail=bavail, f_bsize=BLOCK_SIZE) + with mock_os.monkey_patch("statvfs", patched_statvfs): + result = cli.run(project, args=["build", "file.bst"]) + assert "1025T of available system storage" in result.stderr |