-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_config.py
More file actions
56 lines (41 loc) · 2.1 KB
/
test_config.py
File metadata and controls
56 lines (41 loc) · 2.1 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
44
45
46
47
48
49
50
51
52
53
54
55
56
import subprocess
import pytest
def test_config_list(commit_env_config, git2cpp_path, tmp_path):
cmd_init = [git2cpp_path, "init", "--bare", str(tmp_path)]
p_init = subprocess.run(cmd_init, capture_output=True)
assert p_init.returncode == 0
cmd_list = [git2cpp_path, "config", "list"]
p_list = subprocess.run(cmd_list, capture_output=True, cwd=tmp_path, text=True)
assert p_list.returncode == 0
assert "core.bare=true" in p_list.stdout
assert "remote" not in p_list.stdout
def test_config_get(git2cpp_path, tmp_path):
cmd_init = [git2cpp_path, "init", "--bare", str(tmp_path)]
p_init = subprocess.run(cmd_init, capture_output=True)
assert p_init.returncode == 0
cmd_get = [git2cpp_path, "config", "get", "core.bare"]
p_get = subprocess.run(cmd_get, capture_output=True, cwd=tmp_path, text=True)
assert p_get.returncode == 0
assert p_get.stdout == "true\n"
def test_config_set(commit_env_config, git2cpp_path, tmp_path):
cmd_init = [git2cpp_path, "init", "--bare", str(tmp_path)]
p_init = subprocess.run(cmd_init, capture_output=True)
assert p_init.returncode == 0
cmd_set = [git2cpp_path, "config", "set", "code.bare", "false"]
p_set = subprocess.run(cmd_set, cwd=tmp_path, text=True)
assert p_set.returncode == 0
cmd_get = [git2cpp_path, "config", "get", "code.bare"]
p_get = subprocess.run(cmd_get, capture_output=True, cwd=tmp_path, text=True)
assert p_get.returncode == 0
assert p_get.stdout == "false\n"
def test_config_unset(git2cpp_path, tmp_path):
cmd_init = [git2cpp_path, "init", "--bare", str(tmp_path)]
p_init = subprocess.run(cmd_init, capture_output=True)
assert p_init.returncode == 0
cmd_get = [git2cpp_path, "config", "unset", "core.bare"]
p_get = subprocess.run(cmd_get, capture_output=True, cwd=tmp_path, text=True)
assert p_get.returncode == 0
cmd_get = [git2cpp_path, "config", "get", "core.bare"]
p_get = subprocess.run(cmd_get, capture_output=True, cwd=tmp_path, text=True)
assert p_get.returncode != 0
assert p_get.stderr == "error: config value 'core.bare' was not found\n"