Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3816775

Browse files
author
Christian Riedel
committed
add test cases for cleansed commit msg
1 parent c5acf65 commit 3816775

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎tests/test_add_jira_tag.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,17 @@ class MockBranch: # pylint: disable=too-few-public-methods, missing-class-docst
123123
result = cli_runner.invoke(main, ["--jira-tag=TEST", str(mock_commit_msg_file)])
124124
assert result.exit_code == 0
125125
assert mock_commit_msg_file.read_text() == "TEST-123: commit message 0815"
126+
127+
128+
def test_tag_added_even_when_tag_as_comment(cli_runner, mock_commit_msg_file, monkeypatch):
129+
"""Assert normal use works even when tag is already in message but as comment."""
130+
131+
class MockBranch: # pylint: disable=too-few-public-methods, missing-class-docstring
132+
name = "feat/TEST-123-branch"
133+
134+
monkeypatch.setattr(Repo, "active_branch", MockBranch())
135+
136+
mock_commit_msg_file.write_text("commit message 0815\n#TEST-123")
137+
result = cli_runner.invoke(main, ["--jira-tag=TEST", str(mock_commit_msg_file)])
138+
assert result.exit_code == 0
139+
assert mock_commit_msg_file.read_text() == "TEST-123: commit message 0815\nTEST-123"

‎tests/test_check_jira_tag.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ def test_empty_commit_msg(mock_ini, mock_commit_msg_file, cli_runner):
103103
assert "Commit message is empty." in result.output
104104

105105

106+
def test_empty_commit_msg_but_comments(mock_ini, mock_commit_msg_file, cli_runner):
107+
"""Assert error on empty commit msg."""
108+
mock_commit_msg_file.write_text("\n#Foobar")
109+
110+
result = cli_runner.invoke(
111+
main, ["--jira-tag=TAG", "--jira-url=URL", str(mock_commit_msg_file)]
112+
)
113+
114+
assert result.exit_code == 1
115+
assert "Commit message is empty." in result.output
116+
117+
106118
@pytest.mark.parametrize("commit_msg", ["message", "tag", "tag-", "#tag", "#tag-123"])
107119
def test_missing_tag(commit_msg, mock_ini, mock_commit_msg_file, cli_runner):
108120
"""Assert error on missing tag."""

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /