summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-09-14 15:42:34 +0100
committerJim MacArthur <jim.macarthur@codethink.co.uk>2018-09-19 16:16:28 +0100
commit3ea7fca92cf18d79fccc1a3a20e4ce87fbca47c7 (patch)
tree45d547f923cabff2ef824cf6aa56432d86cf3389
parentf46acc041868fedd3976d319e124203964e3c97f (diff)
downloadbuildstream-3ea7fca92cf18d79fccc1a3a20e4ce87fbca47c7.tar.gz
import_cas.py: More work on test
-rw-r--r--tests/storage/import_cas.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/storage/import_cas.py b/tests/storage/import_cas.py
index e77328da5..d7db43c15 100644
--- a/tests/storage/import_cas.py
+++ b/tests/storage/import_cas.py
@@ -11,7 +11,7 @@ TOP_DIR = os.path.dirname(os.path.realpath(__file__))
class FakeContext():
def __init__(self):
- self.config_cache_quota = "0"
+ self.config_cache_quota = "65536"
def get_projects(self):
return []
@@ -21,6 +21,8 @@ root_filesets = [
[('a/b/c/textfile1', 'This is the replacement textfile 1\n')],
]
+empty_hash_ref = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
+
def generate_import_roots(directory):
for fileset in [1, 2]:
@@ -28,9 +30,9 @@ def generate_import_roots(directory):
for (path, content) in root_filesets[fileset - 1]:
(dirnames, filename) = os.path.split(path)
- os.path.mkdirs(dirnames)
+ os.makedirs(os.path.join(directory, "content", rootname, dirnames))
- with open(os.path.join(tmpdir, rootname, dirnames, filename), "wt") as f:
+ with open(os.path.join(directory, "content", rootname, dirnames, filename), "wt") as f:
f.write(content)
@@ -38,12 +40,16 @@ def test_cas_import(cli, tmpdir):
fake_context = FakeContext()
fake_context.artifactdir = tmpdir
# Create some fake content
+ generate_import_roots(tmpdir)
+
d = CasBasedDirectory(fake_context)
d.import_files(os.path.join(tmpdir, "content", "root1"))
+ assert d.ref.hash != empty_hash_ref
d2 = CasBasedDirectory(fake_context)
d2.import_files(os.path.join(tmpdir, "content", "root2"))
-
+ assert d2.ref.hash != empty_hash_ref
+ print("D2 hash is {}".format(d2.ref.hash))
d.import_files(d2)
d.export_files(os.path.join(tmpdir, "output"))