-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_add.py
More file actions
43 lines (33 loc) · 1.32 KB
/
test_add.py
File metadata and controls
43 lines (33 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
39
40
41
42
43
import subprocess
import pytest
@pytest.mark.parametrize("all_flag", ["", "-A", "--all", "--no-ignore-removal"])
def test_add(xtl_clone, git2cpp_path, tmp_path, all_flag):
assert (tmp_path / "xtl").exists()
xtl_path = tmp_path / "xtl"
p = xtl_path / "mook_file.txt"
p.write_text('')
p2 = xtl_path / "mook_file_2.txt"
p2.write_text('')
cmd_add = [git2cpp_path, 'add']
if all_flag != "":
cmd_add.append(all_flag)
else:
cmd_add.append("mook_file.txt")
p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True)
assert p_add.returncode == 0
cmd_status = [git2cpp_path, 'status', "--long"]
p_status = subprocess.run(cmd_status, cwd=xtl_path, capture_output=True, text=True)
assert p_status.returncode == 0
assert "Changes to be committed" in p_status.stdout
assert "new file" in p_status.stdout
if all_flag != "":
assert "Untracked files" not in p_status.stdout
else:
assert "Untracked files" in p_status.stdout
def test_add_nogit(git2cpp_path, tmp_path):
p = tmp_path / "mook_file.txt"
p.write_text('')
cmd_add = [git2cpp_path, 'add', 'mook_file.txt']
p_add = subprocess.run(cmd_add, cwd=tmp_path, text=True, capture_output=True)
assert p_add.returncode != 0
assert "error: could not find repository at" in p_add.stderr