Skip to content

Commit 3a4a1f3

Browse files
gonsoosarthurzam
authored andcommitted
tests: add tests for Closes tags with resolution
Signed-off-by: Lucio Sauer <watermanpaint@posteo.net> Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 530d4fa commit 3a4a1f3

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/scripts/test_pkgdev_commit.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,36 @@ def test_commit_tags(self, capsys, repo, make_git_repo, tool):
152152
options, _ = tool.parse_args(["commit", opt, "https://bugs.gentoo.org/2"])
153153
assert options.footer == {("Closes", "https://bugs.gentoo.org/2")}
154154

155+
# bug IDs and URLs with good resolutions
156+
for opt in ("-c", "--closes"):
157+
for values, expected in (
158+
(("", "FIXED", "fiXed"), ""),
159+
(("PKGREMOVED", "pkgRemovEd"), " (pkgremoved)"),
160+
(("OBSOLETE", "obSoleTe"), " (obsolete)"),
161+
):
162+
for value in values:
163+
for bug in "1", "https://bugs.gentoo.org/1":
164+
options, _ = tool.parse_args(["commit", opt, f"{bug}:{value}"])
165+
assert options.footer == {
166+
("Closes", f"https://bugs.gentoo.org/1{expected}")
167+
}
168+
169+
# bad bug-resolution pair
170+
for opt in ("-c", "--closes"):
171+
for value, expected in (
172+
(":", "invalid commit tag"),
173+
(":1", "invalid commit tag"),
174+
(":fixed", "invalid commit tag"),
175+
("1:invalid", "should be one of"),
176+
("https://bugs.gentoo.org/1:invalid", "should be one of"),
177+
):
178+
with pytest.raises(SystemExit) as excinfo:
179+
options, _ = tool.parse_args(["commit", opt, value])
180+
assert excinfo.value.code == 2
181+
out, err = capsys.readouterr()
182+
assert not out
183+
assert expected in err
184+
155185
# bad URL
156186
for opt in ("-b", "-c"):
157187
with pytest.raises(SystemExit) as excinfo:

0 commit comments

Comments
 (0)