1
0
Fork 0
mirror of synced 2024-12-22 14:41:07 -05:00
yadm/test/test_git.py

60 lines
1.6 KiB
Python
Raw Normal View History

"""Test git"""
import re
2023-07-10 10:14:33 -04:00
import pytest
2023-07-10 15:43:17 -04:00
@pytest.mark.usefixtures("ds1_copy")
def test_git(runner, yadm_cmd, paths):
"""Test series of passthrough git commands
Passthru unknown commands to Git
Git command 'add' - badfile
Git command 'add'
Git command 'status'
Git command 'commit'
Git command 'log'
"""
# passthru unknown commands to Git
2023-07-10 15:43:17 -04:00
run = runner(command=yadm_cmd("bogus"))
assert run.failure
assert "git: 'bogus' is not a git command." in run.err
assert "See 'git --help'" in run.err
2023-07-10 15:43:17 -04:00
assert run.out == ""
# git command 'add' - badfile
2023-07-10 15:43:17 -04:00
run = runner(command=yadm_cmd("add", "-v", "does_not_exist"))
assert run.code == 128
assert "pathspec 'does_not_exist' did not match any files" in run.err
2023-07-10 15:43:17 -04:00
assert run.out == ""
# git command 'add'
2023-07-10 15:43:17 -04:00
newfile = paths.work.join("test_git")
newfile.write("test_git")
run = runner(command=yadm_cmd("add", "-v", str(newfile)))
assert run.success
2023-07-10 15:43:17 -04:00
assert run.err == ""
assert "add 'test_git'" in run.out
# git command 'status'
2023-07-10 15:43:17 -04:00
run = runner(command=yadm_cmd("status"))
assert run.success
2023-07-10 15:43:17 -04:00
assert run.err == ""
assert re.search(r"new file:\s+test_git", run.out)
# git command 'commit'
2023-07-10 15:43:17 -04:00
run = runner(command=yadm_cmd("commit", "-m", "Add test_git"))
assert run.success
2023-07-10 15:43:17 -04:00
assert run.err == ""
assert "1 file changed" in run.out
assert "1 insertion" in run.out
assert re.search(r"create mode .+ test_git", run.out)
# git command 'log'
2023-07-10 15:43:17 -04:00
run = runner(command=yadm_cmd("log", "--oneline"))
assert run.success
2023-07-10 15:43:17 -04:00
assert run.err == ""
assert "Add test_git" in run.out