]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: add unit test for normalize_path
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 28 Jan 2022 16:21:57 +0000 (11:21 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 23 Feb 2022 21:27:24 +0000 (16:27 -0500)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/nfs/tests/test_nfs.py

index 4688679db4832b3d204109dad80e0ba111b68c73..c31e5b889683b058403842589916b04d4538a61b 100644 (file)
@@ -12,7 +12,7 @@ from rados import ObjectNotFound
 
 from ceph.deployment.service_spec import NFSServiceSpec
 from nfs import Module
-from nfs.export import ExportMgr
+from nfs.export import ExportMgr, normalize_path
 from nfs.export_utils import GaneshaConfParser, Export, RawBlock
 from nfs.cluster import NFSCluster
 from orchestrator import ServiceDescription, DaemonDescription, OrchResult
@@ -1018,3 +1018,19 @@ NFS_CORE_PARAM {
 
     def test_cluster_config(self):
         self._do_mock_test(self._do_test_cluster_config)
+
+
+@pytest.mark.parametrize(
+    "path,expected",
+    [
+        ("/foo/bar/baz", "/foo/bar/baz"),
+        ("/foo/bar/baz/", "/foo/bar/baz"),
+        ("/foo/bar/baz ", "/foo/bar/baz"),
+        ("/foo/./bar/baz", "/foo/bar/baz"),
+        ("/foo/bar/baz/..", "/foo/bar"),
+        ("//foo/bar/baz", "/foo/bar/baz"),
+        ("", ""),
+    ]
+)
+def test_normalize_path(path, expected):
+    assert normalize_path(path) == expected