tests: basic check for base of Object
Check that setting the base of an Object will initialize the tree with the contents of that base on the first write.
This commit is contained in:
parent
4ba91f2f4c
commit
2fa9f86112
1 changed files with 29 additions and 0 deletions
|
|
@ -85,6 +85,35 @@ class TestObjectStore(unittest.TestCase):
|
|||
assert len(os.listdir(f"{object_store.refs}/a/")) == 1
|
||||
assert len(os.listdir(f"{object_store.refs}/b/")) == 1
|
||||
|
||||
def test_object_base(self):
|
||||
# operate with a clean object store
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as tmp:
|
||||
object_store = objectstore.ObjectStore(tmp)
|
||||
with object_store.new() as tree:
|
||||
path = tree.write()
|
||||
p = Path(f"{path}/A")
|
||||
p.touch()
|
||||
object_store.commit(tree, "a")
|
||||
|
||||
with object_store.new() as tree:
|
||||
tree.base = "a"
|
||||
object_store.commit(tree, "b")
|
||||
|
||||
with object_store.new() as tree:
|
||||
tree.base = "b"
|
||||
path = tree.write()
|
||||
p = Path(f"{path}/C")
|
||||
p.touch()
|
||||
object_store.commit(tree, "c")
|
||||
|
||||
assert os.path.exists(f"{object_store.refs}/a/A")
|
||||
assert os.path.exists(f"{object_store.refs}/b/A")
|
||||
assert os.path.exists(f"{object_store.refs}/c/A")
|
||||
assert os.path.exists(f"{object_store.refs}/c/C")
|
||||
|
||||
assert len(os.listdir(object_store.refs)) == 3
|
||||
assert len(os.listdir(object_store.objects)) == 2
|
||||
|
||||
def test_object_copy_on_write(self):
|
||||
# operate with a clean object store
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as tmp:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue