]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/t/thelpers.py
Merge branch 'next' into 'master'
[bup.git] / lib / bup / t / thelpers.py
index ebb80f8ec17af8c58fb363fff4fb90c0fe46cb9d..89cccdaebad7214472c319e6206eb6854b209385 100644 (file)
@@ -51,3 +51,25 @@ def test_strip_symlinked_base_path():
 
     WVPASSEQ(result, "/a")
 
+@wvtest
+def test_graft_path():
+    middle_matching_old_path = "/user"
+    non_matching_old_path = "/usr"
+    matching_old_path = "/home"
+    matching_full_path = "/home/user"
+    new_path = "/opt"
+
+    all_graft_points = [(middle_matching_old_path, new_path),
+                        (non_matching_old_path, new_path),
+                        (matching_old_path, new_path)]
+
+    path = "/home/user/"
+
+    WVPASSEQ(graft_path([(middle_matching_old_path, new_path)], path),
+                        "/home/user")
+    WVPASSEQ(graft_path([(non_matching_old_path, new_path)], path),
+                        "/home/user")
+    WVPASSEQ(graft_path([(matching_old_path, new_path)], path), "/opt/user")
+    WVPASSEQ(graft_path(all_graft_points, path), "/opt/user")
+    WVPASSEQ(graft_path([(matching_full_path, new_path)], path),
+                        "/opt")