|
3 | 3 |
|
4 | 4 | import pytest
|
5 | 5 |
|
6 |
| -from commitizen import git |
| 6 | +from commitizen import cmd, git |
7 | 7 | from tests.utils import FakeCommand, create_file_and_commit
|
8 | 8 |
|
9 | 9 |
|
@@ -73,7 +73,45 @@ def test_get_commits_author_and_email():
|
73 | 73 | assert "@" in commit.author_email
|
74 | 74 |
|
75 | 75 |
|
| 76 | +def test_get_commits_without_email(mocker): |
| 77 | + raw_commit = ( |
| 78 | + "a515bb8f71c403f6f7d1c17b9d8ebf2ce3959395\n" |
| 79 | + "\n" |
| 80 | + "user name\n" |
| 81 | + "\n" |
| 82 | + "----------commit-delimiter----------\n" |
| 83 | + "12d3b4bdaa996ea7067a07660bb5df4772297bdd\n" |
| 84 | + "feat(users): add username\n" |
| 85 | + "user name\n" |
| 86 | + "\n" |
| 87 | + "----------commit-delimiter----------\n" |
| 88 | + ) |
| 89 | + mocker.patch("commitizen.cmd.run", return_value=FakeCommand(out=raw_commit)) |
| 90 | + |
| 91 | + commits = git.get_commits() |
| 92 | + |
| 93 | + assert commits[0].author == "user name" |
| 94 | + assert commits[1].author == "user name" |
| 95 | + |
| 96 | + assert commits[0].author_email == "" |
| 97 | + assert commits[1].author_email == "" |
| 98 | + |
| 99 | + assert commits[0].title == "" |
| 100 | + assert commits[1].title == "feat(users): add username" |
| 101 | + |
| 102 | + |
76 | 103 | def test_get_tag_names_has_correct_arrow_annotation():
|
77 | 104 | arrow_annotation = inspect.getfullargspec(git.get_tag_names).annotations["return"]
|
78 | 105 |
|
79 | 106 | assert arrow_annotation == List[Optional[str]]
|
| 107 | + |
| 108 | + |
| 109 | +def test_get_latest_tag_name(tmp_commitizen_project): |
| 110 | + with tmp_commitizen_project.as_cwd(): |
| 111 | + tag_name = git.get_latest_tag_name() |
| 112 | + assert tag_name is None |
| 113 | + |
| 114 | + create_file_and_commit("feat(test): test") |
| 115 | + cmd.run("git tag 1.0") |
| 116 | + tag_name = git.get_latest_tag_name() |
| 117 | + assert tag_name == "1.0" |
0 commit comments