summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-10-09 14:48:17 +0100
committerBenjamin Schubert <contact@benschubert.me>2019-10-09 16:33:00 +0100
commit285d3ccc24f27863f5572d141665cfc3db0d6d71 (patch)
tree64f7a0189eacf07c6dac08fea501c80f88005ed4
parent372bcab32b37d4f78f3f6a5c0d250d1e65c599bd (diff)
downloadbuildstream-285d3ccc24f27863f5572d141665cfc3db0d6d71.tar.gz
tests/sourcecache/fetch.py: Extract logic to move local cas to remote
This method can be reused and shared, and makes the tests more readable.
-rw-r--r--tests/sourcecache/fetch.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/tests/sourcecache/fetch.py b/tests/sourcecache/fetch.py
index 99c00f120..1571300fb 100644
--- a/tests/sourcecache/fetch.py
+++ b/tests/sourcecache/fetch.py
@@ -34,6 +34,14 @@ from tests.testutils import create_artifact_share, dummy_context
DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
+def move_local_cas_to_remote_source_share(local, remote):
+ shutil.rmtree(os.path.join(remote, 'repo', 'cas'))
+ shutil.move(os.path.join(local, 'source_protos'), os.path.join(remote, 'repo'))
+ shutil.move(os.path.join(local, 'cas'), os.path.join(remote, 'repo'))
+ shutil.rmtree(os.path.join(local, 'sources'))
+ shutil.rmtree(os.path.join(local, 'artifacts'))
+
+
@pytest.mark.datafiles(DATA_DIR)
def test_source_fetch(cli, tmpdir, datafiles):
project_dir = str(datafiles)
@@ -86,16 +94,7 @@ def test_source_fetch(cli, tmpdir, datafiles):
sourcecache = context.sourcecache
digest = sourcecache.export(source)._get_digest()
- # Move source in local cas to repo
- shutil.rmtree(os.path.join(str(tmpdir), 'sourceshare', 'repo', 'cas'))
- shutil.move(
- os.path.join(str(tmpdir), 'cache', 'source_protos'),
- os.path.join(str(tmpdir), 'sourceshare', 'repo'))
- shutil.move(
- os.path.join(str(tmpdir), 'cache', 'cas'),
- os.path.join(str(tmpdir), 'sourceshare', 'repo'))
- shutil.rmtree(os.path.join(str(tmpdir), 'cache', 'sources'))
- shutil.rmtree(os.path.join(str(tmpdir), 'cache', 'artifacts'))
+ move_local_cas_to_remote_source_share(str(cache_dir), share.directory)
# check the share has the object
assert share.has_object(digest)