summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-19 10:49:50 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-23 08:57:53 -0500
commit0098a900a3c47b93a8b96686581aec3622d44a22 (patch)
treeed9e69355cb78e0c6b8d1c22d8bbc2c44b3965a7
parent528e8ed738567db883fcfe38f2924af29d0d033d (diff)
downloadbuildstream-0098a900a3c47b93a8b96686581aec3622d44a22.tar.gz
tests: Migrated cache quota test into artifactcache/cache_size.py
Instead of sitting mysteriously alone in internals/utils.py
-rw-r--r--tests/artifactcache/cache_size.py28
-rw-r--r--tests/internals/utils.py34
2 files changed, 28 insertions, 34 deletions
diff --git a/tests/artifactcache/cache_size.py b/tests/artifactcache/cache_size.py
index 0d12cda8c..45c10d49a 100644
--- a/tests/artifactcache/cache_size.py
+++ b/tests/artifactcache/cache_size.py
@@ -1,5 +1,6 @@
import os
import pytest
+from unittest import mock
from buildstream import _yaml
from buildstream._artifactcache import CACHE_SIZE_FILE
@@ -60,3 +61,30 @@ def test_cache_size_write(cli, tmpdir):
with open(sizefile, "r") as f:
size_data = f.read()
size = int(size_data)
+
+
+def test_quota_over_1024T(cli, tmpdir):
+ KiB = 1024
+ MiB = (KiB * 1024)
+ GiB = (MiB * 1024)
+ TiB = (GiB * 1024)
+
+ cli.configure({
+ 'cache': {
+ 'quota': 2048 * TiB
+ }
+ })
+ project = tmpdir.join("main")
+ os.makedirs(str(project))
+ _yaml.dump({'name': 'main'}, str(project.join("project.conf")))
+
+ volume_space_patch = mock.patch(
+ "buildstream._artifactcache.ArtifactCache._get_volume_space_info_for",
+ autospec=True,
+ return_value=(1025 * TiB, 1025 * TiB)
+ )
+
+ with volume_space_patch:
+ result = cli.run(project, args=["build", "file.bst"])
+ failure_msg = 'Your system does not have enough available space to support the cache quota specified.'
+ assert failure_msg in result.stderr
diff --git a/tests/internals/utils.py b/tests/internals/utils.py
deleted file mode 100644
index a34d3cda5..000000000
--- a/tests/internals/utils.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import os
-from unittest import mock
-
-from buildstream import _yaml
-
-from ..testutils.runcli import cli
-
-
-KiB = 1024
-MiB = (KiB * 1024)
-GiB = (MiB * 1024)
-TiB = (GiB * 1024)
-
-
-def test_parse_size_over_1024T(cli, tmpdir):
- cli.configure({
- 'cache': {
- 'quota': 2048 * TiB
- }
- })
- project = tmpdir.join("main")
- os.makedirs(str(project))
- _yaml.dump({'name': 'main'}, str(project.join("project.conf")))
-
- volume_space_patch = mock.patch(
- "buildstream._artifactcache.ArtifactCache._get_volume_space_info_for",
- autospec=True,
- return_value=(1025 * TiB, 1025 * TiB)
- )
-
- with volume_space_patch:
- result = cli.run(project, args=["build", "file.bst"])
- failure_msg = 'Your system does not have enough available space to support the cache quota specified.'
- assert failure_msg in result.stderr