-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_reset.py
More file actions
39 lines (28 loc) · 1.32 KB
/
test_reset.py
File metadata and controls
39 lines (28 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import subprocess
import pytest
def test_reset(xtl_clone, git_config, git2cpp_path, tmp_path, monkeypatch):
assert (tmp_path / "xtl").exists()
xtl_path = tmp_path / "xtl"
p = xtl_path / "mook_file.txt"
p.write_text('')
cmd_add = [git2cpp_path, 'add', "mook_file.txt"]
p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True)
assert p_add.returncode == 0
cmd_commit = [git2cpp_path, 'commit', "-m", "test commit"]
p_commit = subprocess.run(cmd_commit, cwd=xtl_path, text=True)
assert p_commit.returncode == 0
cmd_log = [git2cpp_path, 'log']
p_log = subprocess.run(cmd_log, capture_output=True, cwd=xtl_path, text=True)
assert p_log.returncode == 0
assert "Jane Doe" in p_log.stdout
cmd_reset = [git2cpp_path, "reset", "--hard", "HEAD~1"]
p_reset = subprocess.run(cmd_reset, capture_output=True, cwd=xtl_path, text=True)
assert p_reset.returncode == 0
cmd_log_2 = [git2cpp_path, 'log']
p_log = subprocess.run(cmd_log_2, capture_output=True, cwd=xtl_path, text=True)
assert p_log.returncode == 0
assert "Jane Doe" not in p_log.stdout
def test_reset_nogit(git2cpp_path, tmp_path):
cmd_reset = [git2cpp_path, "reset", "--hard", "HEAD~1"]
p_reset = subprocess.run(cmd_reset, capture_output=True, cwd=tmp_path, text=True)
assert p_reset.returncode != 0