2015-10-17 17:35:39 -03:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.git_two_dashes import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-10-17 17:35:39 -03:00
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
output = 'error: did you mean `{}` (with two dashes ?)'.format
|
2015-10-17 17:35:39 -03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('git add -patch', output('--patch')),
|
|
|
|
Command('git checkout -patch', output('--patch')),
|
|
|
|
Command('git commit -amend', output('--amend')),
|
|
|
|
Command('git push -tags', output('--tags')),
|
|
|
|
Command('git rebase -continue', output('--continue'))])
|
2015-10-17 17:35:39 -03:00
|
|
|
def test_match(command):
|
|
|
|
assert match(command)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('git add --patch', ''),
|
|
|
|
Command('git checkout --patch', ''),
|
|
|
|
Command('git commit --amend', ''),
|
|
|
|
Command('git push --tags', ''),
|
|
|
|
Command('git rebase --continue', '')])
|
2015-10-17 17:35:39 -03:00
|
|
|
def test_not_match(command):
|
|
|
|
assert not match(command)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command, output', [
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('git add -patch', output('--patch')),
|
2015-10-17 17:35:39 -03:00
|
|
|
'git add --patch'),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('git checkout -patch', output('--patch')),
|
2015-10-17 17:35:39 -03:00
|
|
|
'git checkout --patch'),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('git checkout -patch', output('--patch')),
|
2015-10-17 17:35:39 -03:00
|
|
|
'git checkout --patch'),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('git init -bare', output('--bare')),
|
2015-10-17 17:35:39 -03:00
|
|
|
'git init --bare'),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('git commit -amend', output('--amend')),
|
2015-10-17 17:35:39 -03:00
|
|
|
'git commit --amend'),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('git push -tags', output('--tags')),
|
2015-10-17 17:35:39 -03:00
|
|
|
'git push --tags'),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('git rebase -continue', output('--continue')),
|
2015-10-17 17:35:39 -03:00
|
|
|
'git rebase --continue')])
|
|
|
|
def test_get_new_command(command, output):
|
|
|
|
assert get_new_command(command) == output
|