| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,3 +32,37 @@ def test_commit(xtl_clone, commit_env_config, git2cpp_path, tmp_path, all_flag): | |||
| 32 | 32 | ) | |
| 33 | 33 | assert p_status_2.returncode == 0 | |
| 34 | 34 | assert "mook_file" not in p_status_2.stdout | |
| 35 | + | ||
| 36 | + | ||
| 37 | + @pytest.mark.parametrize("commit_msg", ["Added file", ""]) | ||
| 38 | + def test_commit_message_via_stdin(commit_env_config, git2cpp_path, tmp_path, run_in_tmp_path, commit_msg): | ||
| 39 | + cmd = [git2cpp_path, "init", "."] | ||
| 40 | + p_init = subprocess.run(cmd) | ||
| 41 | + assert p_init.returncode == 0 | ||
| 42 | + | ||
| 43 | + (tmp_path / "file.txt").write_text("Some text") | ||
| 44 | + | ||
| 45 | + cmd_add = [git2cpp_path, "add", "file.txt"] | ||
| 46 | + p_add = subprocess.run(cmd_add) | ||
| 47 | + assert p_add.returncode == 0 | ||
| 48 | + | ||
| 49 | + cmd_commit = [git2cpp_path, "commit"] | ||
| 50 | + p_commit = subprocess.run(cmd_commit, text=True, capture_output=True, input=commit_msg) | ||
| 51 | + | ||
| 52 | + if commit_msg == "": | ||
| 53 | + # No commit message | ||
| 54 | + assert p_commit.returncode != 0 | ||
| 55 | + assert "Aborting, no commit message specified" in p_commit.stderr | ||
| 56 | + else: | ||
| 57 | + # Valid commit message | ||
| 58 | + assert p_commit.returncode == 0 | ||
| 59 | + | ||
| 60 | + cmd_log = [git2cpp_path, "log"] | ||
| 61 | + p_log = subprocess.run(cmd_log, text=True, capture_output=True) | ||
| 62 | + assert p_log.returncode == 0 | ||
| 63 | + lines = p_log.stdout.splitlines() | ||
| 64 | + | ||
| 65 | + assert "commit" in lines[0] | ||
| 66 | + assert "Author:" in lines[1] | ||
| 67 | + assert "Date" in lines[2] | ||
| 68 | + assert commit_msg in lines[4] | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments