1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2024-10-27 20:34:27 +00:00
TheLocehiliosan_yadm/test/test_default_remote_branch.py

28 lines
809 B
Python
Raw Normal View History

"""Unit tests: _default_remote_branch()"""
import pytest
@pytest.mark.parametrize('condition', ['found', 'missing'])
def test(runner, paths, condition):
"""Test _default_remote_branch()"""
test_branch = 'test/branch'
output = f'ref: refs/heads/{test_branch}\\tHEAD\\n'
if condition == 'missing':
output = 'output that is missing ref'
script = f"""
YADM_TEST=1 source {paths.pgm}
function git() {{
printf '{output}';
printf 'mock stderr\\n' 1>&2
}}
_default_remote_branch URL
"""
print(condition)
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
if condition == 'found':
assert run.out.strip() == test_branch
else:
assert run.out.strip() == 'master'