2018-07-11 08:50:42 -04:00
|
|
|
"""Test git"""
|
|
|
|
|
|
|
|
import re
|
2023-07-10 10:14:33 -04:00
|
|
|
|
2018-07-11 08:50:42 -04:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2023-07-10 15:43:17 -04:00
|
|
|
@pytest.mark.usefixtures("ds1_copy")
|
2020-11-17 15:38:31 -05:00
|
|
|
def test_git(runner, yadm_cmd, paths):
|
2018-07-11 08:50:42 -04:00
|
|
|
"""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"))
|
2018-07-11 08:50:42 -04:00
|
|
|
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 == ""
|
2018-07-11 08:50:42 -04:00
|
|
|
|
|
|
|
# git command 'add' - badfile
|
2023-07-10 15:43:17 -04:00
|
|
|
run = runner(command=yadm_cmd("add", "-v", "does_not_exist"))
|
2018-07-11 08:50:42 -04:00
|
|
|
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 == ""
|
2018-07-11 08:50:42 -04:00
|
|
|
|
|
|
|
# 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)))
|
2018-07-11 08:50:42 -04:00
|
|
|
assert run.success
|
2023-07-10 15:43:17 -04:00
|
|
|
assert run.err == ""
|
2018-07-11 08:50:42 -04:00
|
|
|
assert "add 'test_git'" in run.out
|
|
|
|
|
|
|
|
# git command 'status'
|
2023-07-10 15:43:17 -04:00
|
|
|
run = runner(command=yadm_cmd("status"))
|
2018-07-11 08:50:42 -04:00
|
|
|
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)
|
2018-07-11 08:50:42 -04:00
|
|
|
|
|
|
|
# git command 'commit'
|
2023-07-10 15:43:17 -04:00
|
|
|
run = runner(command=yadm_cmd("commit", "-m", "Add test_git"))
|
2018-07-11 08:50:42 -04:00
|
|
|
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)
|
2018-07-11 08:50:42 -04:00
|
|
|
|
|
|
|
# git command 'log'
|
2023-07-10 15:43:17 -04:00
|
|
|
run = runner(command=yadm_cmd("log", "--oneline"))
|
2018-07-11 08:50:42 -04:00
|
|
|
assert run.success
|
2023-07-10 15:43:17 -04:00
|
|
|
assert run.err == ""
|
|
|
|
assert "Add test_git" in run.out
|