commit:     3a4a1f3b000d297f6bc9ab6b44e68d991e74b28c
Author:     Lucio Sauer <watermanpaint <AT> posteo <DOT> net>
AuthorDate: Sat Jul 20 15:02:16 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Jul 20 15:37:22 2024 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=3a4a1f3b

tests: add tests for Closes tags with resolution

Signed-off-by: Lucio Sauer <watermanpaint <AT> posteo.net>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 tests/scripts/test_pkgdev_commit.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tests/scripts/test_pkgdev_commit.py 
b/tests/scripts/test_pkgdev_commit.py
index ff93db8..04fc16a 100644
--- a/tests/scripts/test_pkgdev_commit.py
+++ b/tests/scripts/test_pkgdev_commit.py
@@ -152,6 +152,36 @@ class TestPkgdevCommitParseArgs:
                 options, _ = tool.parse_args(["commit", opt, 
"https://bugs.gentoo.org/2";])
                 assert options.footer == {("Closes", 
"https://bugs.gentoo.org/2";)}
 
+            # bug IDs and URLs with good resolutions
+            for opt in ("-c", "--closes"):
+                for values, expected in (
+                    (("", "FIXED", "fiXed"), ""),
+                    (("PKGREMOVED", "pkgRemovEd"), " (pkgremoved)"),
+                    (("OBSOLETE", "obSoleTe"), " (obsolete)"),
+                ):
+                    for value in values:
+                        for bug in "1", "https://bugs.gentoo.org/1":
+                            options, _ = tool.parse_args(["commit", opt, 
f"{bug}:{value}"])
+                            assert options.footer == {
+                                ("Closes", 
f"https://bugs.gentoo.org/1{expected}";)
+                            }
+
+            # bad bug-resolution pair
+            for opt in ("-c", "--closes"):
+                for value, expected in (
+                    (":", "invalid commit tag"),
+                    (":1", "invalid commit tag"),
+                    (":fixed", "invalid commit tag"),
+                    ("1:invalid", "should be one of"),
+                    ("https://bugs.gentoo.org/1:invalid";, "should be one of"),
+                ):
+                    with pytest.raises(SystemExit) as excinfo:
+                        options, _ = tool.parse_args(["commit", opt, value])
+                    assert excinfo.value.code == 2
+                    out, err = capsys.readouterr()
+                    assert not out
+                    assert expected in err
+
             # bad URL
             for opt in ("-b", "-c"):
                 with pytest.raises(SystemExit) as excinfo:

Reply via email to