You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/11/10 10:10:49 UTC
[buildstream] 01/03: tests/frontend/mirror.py: Test that mirrors
set from user configuration also work
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch tristan/mirrors
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit f9ed353268237ac56553bd3499579a9be937ca6a
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Wed Nov 10 19:10:01 2021 +0900
tests/frontend/mirror.py: Test that mirrors set from user configuration also work
---
tests/frontend/mirror.py | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/tests/frontend/mirror.py b/tests/frontend/mirror.py
index db5d6bf..c3cfbf0 100644
--- a/tests/frontend/mirror.py
+++ b/tests/frontend/mirror.py
@@ -38,19 +38,25 @@ def generate_element(output_file):
return element
-def generate_project():
+MIRROR_LIST = [
+ {"name": "middle-earth", "aliases": {"foo": ["OOF/"], "bar": ["RAB/"],},},
+ {"name": "arrakis", "aliases": {"foo": ["OFO/"], "bar": ["RBA/"],},},
+ {"name": "oz", "aliases": {"foo": ["ooF/"], "bar": ["raB/"],}},
+]
+
+
+def generate_project(define_mirrors=True):
project = {
"name": "test",
"min-version": "2.0",
"element-path": "elements",
"aliases": {"foo": "FOO/", "bar": "BAR/",},
- "mirrors": [
- {"name": "middle-earth", "aliases": {"foo": ["OOF/"], "bar": ["RAB/"],},},
- {"name": "arrakis", "aliases": {"foo": ["OFO/"], "bar": ["RBA/"],},},
- {"name": "oz", "aliases": {"foo": ["ooF/"], "bar": ["raB/"],}},
- ],
"plugins": [{"origin": "local", "path": "sources", "sources": ["fetch_source"]}],
}
+
+ if define_mirrors:
+ project["mirrors"] = MIRROR_LIST
+
return project
@@ -116,7 +122,8 @@ def test_mirror_fetch_ref_storage(cli, tmpdir, datafiles, ref_storage, mirror):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.usefixtures("datafiles")
-def test_mirror_fetch_multi(cli, tmpdir):
+@pytest.mark.parametrize("project_config", [True, False], ids=["user-config", "project-config"])
+def test_mirror_fetch_multi(cli, tmpdir, project_config):
output_file = os.path.join(str(tmpdir), "output.txt")
project_dir = str(tmpdir)
element_dir = os.path.join(project_dir, "elements")
@@ -127,9 +134,12 @@ def test_mirror_fetch_multi(cli, tmpdir):
_yaml.roundtrip_dump(element, element_path)
project_file = os.path.join(project_dir, "project.conf")
- project = generate_project()
+ project = generate_project(project_config)
_yaml.roundtrip_dump(project, project_file)
+ if not project_config:
+ cli.configure({"projects": {"test": {"mirrors": MIRROR_LIST}}})
+
result = cli.run(project=project_dir, args=["source", "fetch", element_name])
result.assert_success()
with open(output_file, encoding="utf-8") as f: