From ffa95fbc796aa5c00eaa32138291c0ef2a48949a Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 28 Jan 2022 11:21:57 -0500 Subject: [PATCH] mgr/nfs: add unit test for normalize_path Signed-off-by: John Mulligan --- src/pybind/mgr/nfs/tests/test_nfs.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/nfs/tests/test_nfs.py b/src/pybind/mgr/nfs/tests/test_nfs.py index 4688679db4832..c31e5b889683b 100644 --- a/src/pybind/mgr/nfs/tests/test_nfs.py +++ b/src/pybind/mgr/nfs/tests/test_nfs.py @@ -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 -- 2.39.5