|
| 1 | +import subprocess |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | + |
| 6 | +def test_reset(xtl_clone, git_config, git2cpp_path, tmp_path, monkeypatch): |
| 7 | + assert (tmp_path / "xtl").exists() |
| 8 | + xtl_path = tmp_path / "xtl" |
| 9 | + |
| 10 | + p = xtl_path / "mook_file.txt" |
| 11 | + p.write_text('') |
| 12 | + |
| 13 | + cmd_add = [git2cpp_path, 'add', "mook_file.txt"] |
| 14 | + p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True) |
| 15 | + assert p_add.returncode == 0 |
| 16 | + |
| 17 | + cmd_commit = [git2cpp_path, 'commit', "-m", "test commit"] |
| 18 | + p_commit = subprocess.run(cmd_commit, cwd=xtl_path, text=True) |
| 19 | + assert p_commit.returncode == 0 |
| 20 | + |
| 21 | + cmd_log = [git2cpp_path, 'log'] |
| 22 | + p_log = subprocess.run(cmd_log, capture_output=True, cwd=xtl_path, text=True) |
| 23 | + assert p_log.returncode == 0 |
| 24 | + assert "Jane Doe" in p_log.stdout |
| 25 | + |
| 26 | + cmd_reset = [git2cpp_path, "reset", "--hard", "HEAD~1"] |
| 27 | + p_reset = subprocess.run(cmd_reset, capture_output=True, cwd=xtl_path, text=True) |
| 28 | + assert p_reset.returncode == 0 |
| 29 | + |
| 30 | + cmd_log_2 = [git2cpp_path, 'log'] |
| 31 | + p_log = subprocess.run(cmd_log_2, capture_output=True, cwd=xtl_path, text=True) |
| 32 | + assert p_log.returncode == 0 |
| 33 | + assert "Jane Doe" not in p_log.stdout |
0 commit comments