2018-01-16 20:03:56 -05:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.git_merge_unrelated import match, get_new_command
|
|
|
|
from thefuck.types import Command
|
|
|
|
|
|
|
|
|
2018-11-21 19:43:01 +01:00
|
|
|
output = 'fatal: refusing to merge unrelated histories'
|
2018-01-16 20:03:56 -05:00
|
|
|
|
|
|
|
|
2018-11-21 19:43:01 +01:00
|
|
|
def test_match():
|
2018-01-16 20:03:56 -05:00
|
|
|
assert match(Command('git merge test', output))
|
|
|
|
assert not match(Command('git merge master', ''))
|
|
|
|
assert not match(Command('ls', output))
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
2018-11-21 19:43:01 +01:00
|
|
|
(Command('git merge local', output),
|
2018-01-16 20:03:56 -05:00
|
|
|
'git merge local --allow-unrelated-histories'),
|
2018-11-21 19:43:01 +01:00
|
|
|
(Command('git merge -m "test" local', output),
|
2018-01-16 20:03:56 -05:00
|
|
|
'git merge -m "test" local --allow-unrelated-histories'),
|
2018-11-21 19:43:01 +01:00
|
|
|
(Command('git merge -m "test local" local', output),
|
2018-01-16 20:03:56 -05:00
|
|
|
'git merge -m "test local" local --allow-unrelated-histories')])
|
|
|
|
def test_get_new_command(command, new_command):
|
|
|
|
assert get_new_command(command) == new_command
|