2018-07-11 12:50:42 +00:00
|
|
|
"""Test git"""
|
|
|
|
|
|
|
|
import re
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.usefixtures('ds1_copy')
|
2020-11-17 20:38:31 +00:00
|
|
|
def test_git(runner, yadm_cmd, paths):
|
2018-07-11 12:50:42 +00: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
|
2020-11-17 20:38:31 +00:00
|
|
|
run = runner(command=yadm_cmd('bogus'))
|
2018-07-11 12:50:42 +00:00
|
|
|
assert run.failure
|
|
|
|
assert "git: 'bogus' is not a git command." in run.err
|
|
|
|
assert "See 'git --help'" in run.err
|
|
|
|
assert run.out == ''
|
|
|
|
|
|
|
|
# git command 'add' - badfile
|
2020-11-17 20:38:31 +00:00
|
|
|
run = runner(command=yadm_cmd('add', '-v', 'does_not_exist'))
|
2018-07-11 12:50:42 +00:00
|
|
|
assert run.code == 128
|
|
|
|
assert "pathspec 'does_not_exist' did not match any files" in run.err
|
|
|
|
assert run.out == ''
|
|
|
|
|
|
|
|
# git command 'add'
|
|
|
|
newfile = paths.work.join('test_git')
|
|
|
|
newfile.write('test_git')
|
2020-11-17 20:38:31 +00:00
|
|
|
run = runner(command=yadm_cmd('add', '-v', str(newfile)))
|
2018-07-11 12:50:42 +00:00
|
|
|
assert run.success
|
|
|
|
assert run.err == ''
|
|
|
|
assert "add 'test_git'" in run.out
|
|
|
|
|
|
|
|
# git command 'status'
|
2020-11-17 20:38:31 +00:00
|
|
|
run = runner(command=yadm_cmd('status'))
|
2018-07-11 12:50:42 +00:00
|
|
|
assert run.success
|
|
|
|
assert run.err == ''
|
|
|
|
assert re.search(r'new file:\s+test_git', run.out)
|
|
|
|
|
|
|
|
# git command 'commit'
|
2020-11-17 20:38:31 +00:00
|
|
|
run = runner(command=yadm_cmd('commit', '-m', 'Add test_git'))
|
2018-07-11 12:50:42 +00:00
|
|
|
assert run.success
|
|
|
|
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'
|
2020-11-17 20:38:31 +00:00
|
|
|
run = runner(command=yadm_cmd('log', '--oneline'))
|
2018-07-11 12:50:42 +00:00
|
|
|
assert run.success
|
|
|
|
assert run.err == ''
|
|
|
|
assert 'Add test_git' in run.out
|