Skip to content

Commit a2d6312

Browse files
committed
test(git): extend test for is_staging_clean
1 parent e92e07f commit a2d6312

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

‎commitizen/git.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def find_git_project_root() -> Optional[Path]:
154154

155155

156156
def is_staging_clean() -> bool:
157-
"""Check if staing is clean."""
157+
"""Check if staging is clean."""
158158
c = cmd.run("git diff --no-ext-diff --cached --name-only")
159159
return not bool(c.out)
160160

‎tests/test_git.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_get_commits_author_and_email():
7070
create_file_and_commit("fix: username exception")
7171
commit = git.get_commits()[0]
7272

73-
assert commit.author is not ""
73+
assert commit.author != ""
7474
assert "@" in commit.author_email
7575

7676

@@ -176,12 +176,30 @@ def test_get_latest_tag_name(tmp_commitizen_project):
176176
assert tag_name == "1.0"
177177

178178

179-
def test_is_staging_clean(tmp_commitizen_project):
179+
def test_is_staging_clean_when_adding_file(tmp_commitizen_project):
180+
with tmp_commitizen_project.as_cwd():
181+
assert git.is_staging_clean() is True
182+
183+
cmd.run("touch test_file")
184+
185+
assert git.is_staging_clean() is True
186+
187+
cmd.run("git add test_file")
188+
189+
assert git.is_staging_clean() is False
190+
191+
192+
def test_is_staging_clean_when_updating_file(tmp_commitizen_project):
180193
with tmp_commitizen_project.as_cwd():
181194
assert git.is_staging_clean() is True
182195

183196
cmd.run("touch test_file")
184197
cmd.run("git add test_file")
198+
cmd.run("git commit -m 'add test_file'")
185199
cmd.run("echo 'test' > test_file")
186200

201+
assert git.is_staging_clean() is True
202+
203+
cmd.run("git add test_file")
204+
187205
assert git.is_staging_clean() is False

0 commit comments

Comments
 (0)