diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:54:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:58:39 +0000 |
commit | 129a1fb4dbc375be0fa926964aa1be46a0cdbbef (patch) | |
tree | 04c0088df47415b24a5be1325d3656b8c3881c04 /tests/test_symlink_normalization.py | |
parent | Initial commit. (diff) | |
download | debputy-129a1fb4dbc375be0fa926964aa1be46a0cdbbef.tar.xz debputy-129a1fb4dbc375be0fa926964aa1be46a0cdbbef.zip |
Adding upstream version 0.1.21.upstream/0.1.21
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_symlink_normalization.py')
-rw-r--r-- | tests/test_symlink_normalization.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_symlink_normalization.py b/tests/test_symlink_normalization.py new file mode 100644 index 0000000..0b11dc8 --- /dev/null +++ b/tests/test_symlink_normalization.py @@ -0,0 +1,35 @@ +import pytest + +from debputy.util import debian_policy_normalize_symlink_target + + +@pytest.mark.parametrize( + "link_path,link_target,expected", + [ + ("usr/share/doc/pkg/my-symlink", "/etc/foo.conf", "/etc/foo.conf"), + ("usr/share/doc/pkg/my-symlink", "/usr/share/doc/pkg", "."), + ("usr/share/doc/pkg/my-symlink", "/usr/share/doc/pkg/.", "."), + ("usr/share/doc/pkg/my-symlink", "/usr/share/bar/../doc/pkg/.", "."), + ( + "usr/share/doc/pkg/my-symlink", + "/usr/share/bar/../doc/pkg/../other-pkg", + "../other-pkg", + ), + ("usr/share/doc/pkg/my-symlink", "/usr/share/doc/other-pkg/.", "../other-pkg"), + ("usr/share/doc/pkg/my-symlink", "../other-pkg/.", "../other-pkg"), + ("usr/share/doc/pkg/my-symlink", "/usr/share/doc/other-pkg", "../other-pkg"), + ("usr/share/doc/pkg/my-symlink", "../other-pkg", "../other-pkg"), + ( + "usr/share/doc/pkg/my-symlink", + "/usr/share/doc/pkg/../../../../etc/foo.conf", + "/etc/foo.conf", + ), + ], +) +def test_symlink_normalization(link_path: str, link_target: str, expected: str) -> None: + actual = debian_policy_normalize_symlink_target( + link_path, + link_target, + normalize_link_path=True, + ) + assert actual == expected |