FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add test for commit message via stdin by ianthomas23 · Pull Request #101 · QuantStack/git2cpp · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
34 changes: 34 additions & 0 deletions test/test_commit.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,37 @@ def test_commit(xtl_clone, commit_env_config, git2cpp_path, tmp_path, all_flag):
)
assert p_status_2.returncode == 0
assert "mook_file" not in p_status_2.stdout


@pytest.mark.parametrize("commit_msg", ["Added file", ""])
def test_commit_message_via_stdin(commit_env_config, git2cpp_path, tmp_path, run_in_tmp_path, commit_msg):
cmd = [git2cpp_path, "init", "."]
p_init = subprocess.run(cmd)
assert p_init.returncode == 0

(tmp_path / "file.txt").write_text("Some text")

cmd_add = [git2cpp_path, "add", "file.txt"]
p_add = subprocess.run(cmd_add)
assert p_add.returncode == 0

cmd_commit = [git2cpp_path, "commit"]
p_commit = subprocess.run(cmd_commit, text=True, capture_output=True, input=commit_msg)

if commit_msg == "":
# No commit message
assert p_commit.returncode != 0
assert "Aborting, no commit message specified" in p_commit.stderr
else:
# Valid commit message
assert p_commit.returncode == 0

cmd_log = [git2cpp_path, "log"]
p_log = subprocess.run(cmd_log, text=True, capture_output=True)
assert p_log.returncode == 0
lines = p_log.stdout.splitlines()

assert "commit" in lines[0]
assert "Author:" in lines[1]
assert "Date" in lines[2]
assert commit_msg in lines[4]

Back | FazBrowse Home | New Git URL