Add the gifn-apply test tool
Add a tool that checks out the repositories mentioned in
a git-if-needed patch series, runs gif-it-needed, and performs
some checks on its operation. This tool will eventually be used in
a Zuul test job for this repository.
Change-Id: Id02fb7c21f5ab34d9639bf845fcc3961d929b13b
diff --git a/tools/git-if-needed/python/unit_tests/test_util.py b/tools/git-if-needed/python/unit_tests/test_util.py
new file mode 100644
index 0000000..bdcb5ad
--- /dev/null
+++ b/tools/git-if-needed/python/unit_tests/test_util.py
@@ -0,0 +1,21 @@
+# SPDX-FileCopyrightText: StorPool <support@storpool.com>
+# SPDX-License-Identifier: BSD-2-Clause
+"""Test the gifn_apply.util functions."""
+
+import pytest
+
+from gifn_apply import util
+
+
+@pytest.mark.parametrize(
+ ("value", "prefix", "expected"),
+ [
+ ("hello", "goodbye", "hello"),
+ ("hello", "hel", "lo"),
+ ("hel", "hello", "hel"),
+ ("hello", "hello", ""),
+ ],
+)
+def test_remove_prefix(value: str, prefix: str, expected: str) -> None:
+ """Test our hand-rolled str.removeprefix() implementation."""
+ assert util.str_removeprefix(value, prefix) == expected